我正在尝试为Int
创建一个扩展,它会逐渐增加其值。但它总是给我错误:
Closure不能隐式捕获变异的自身参数
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)
)
)
}
}