Reputation: 188
I'm trying to call a function that takes in an Array as a reference
spill(pool: &objectPool)
And the function will make the array pops its first element to run some animations. Once the animation is complete, the element gets put back to the Array
func spill(pool: inout [Object]) {
let spill = pool[0]
spriteComponent.node.addChild(spill.sprite)
pool.removeFirst()
spill.sprite.run(SKAction.sequence([spill.spriteAnimation, SKAction.removeFromParent()])) {
pool.append(spill)
//Do some other works
}
}
However, I get the following error message:
Escaping closure captures 'inout' parameter 'pool'
How do I get this function to work? Thanks in advance.
Upvotes: 0
Views: 57