1

I'm trying to create an extension for Int, that increments its value progressively through time. But it always gives me the error:

Closure cannot implicitly capture a mutating self parameter

extension Int {

mutating func increment(_ value: Int, withDuration d: CGFloat, parent: SKNode) {
    let dx = CGFloat(value)*0.1/d
    parent.run(
        .repeat(
            .sequence([
                .run { self += Int(dx) }, //Error Here!
                .wait(forDuration: 0.1)
                ]),
            count: Int(d/0.1)
        )
    )

}

}
Fayyouz
  • 682
  • 7
  • 18

0 Answers0