简体   繁体   中英

Triggering the end of a while loop using the completion of SKAction

I'm trying to use a "while loop" while my SKSpritenode is animating and I want to trigger the end of the SKAction to trigger the end of the loop. This is my attempt

while (orgNode.hasActions) {
   //render the background
}

what I want to do is create a bottom up sweep effect that changes the sprite nodes texture underneath the originNode's position, so that the user sees the sweeping motion of the node changing the background color.

You can override the update or didEvaluateActions function of the SKScene if you want to update the node every frame. didEvaluateActions function is called in each frame after all the SKActions are evaluated. The update function is called before all actions are evaluated.

override func didEvaluateActions() {
    if node.hasActions()
    {
        println("Running Action")
    }
}

The following image shows which all functions are called in each frame and in what order.

在此处输入图片说明
For more information : https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Introduction/Introduction.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM