arraysswiftsprite-kitboolean

Boolean in action array


I have an action array, and when this array is completed, I want to change value Move to false.

This is my array:

actionArray.addObject(SKAction.moveToY(hond.position.y + 0.4 * frame2.size.height, duration: timee/10))
actionArray.addObject(SKAction.moveToY(hond.position.y + 0.6 * frame2.size.height, duration: timee/12))
actionArray.addObject(SKAction.moveToY(hond.position.y + 0.7 * frame2.size.height, duration: timee/14))
actionArray.addObject(SKAction.moveToY(hond.position.y + 0.75 * frame2.size.height, duration: timee/16))
hond.runAction(SKAction.sequence(actionArray))

How do I add a object that will change the boolean add the end of the array?


Solution

  • SKAction Class Reference : https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKAction_Ref/index.html#//apple_ref/occ/clm/SKAction/runBlock:

    You can use a runBlock: action, from SKAction and add it at the end of your sequence.

    For example :

    SKAction.runBlock(self.aFunction)
    
    func aFunction() {
        // Change your boolean value here
    }
    

    Or :

    SKAction.runBlock({ self.yourBooleanProperty = false })