How to interrupt a SpriteKit sequence of actions and resume as if there was no interruption

前端 未结 1 1650
独厮守ぢ
独厮守ぢ 2020-12-20 19:30

I would like to interrupt the sequence below for 2 seconds and resume to where it would have been if it wasn\'t interrupted in the first place.

For example, from the

相关标签:
1条回答
  • 2020-12-20 20:30

    To interrupt the action sequence like yours, you can simply put in pause your sprite with:

    sprite.isPaused = true
    

    and to resume the action you can do:

    sprite.isPaused = false
    

    To make some specific action after a time you can simply made:

    sprite.run(SKAction.wait(forDuration: 2.5),completion:{
       print("after 2.5 sec do..")
    })
    

    To answer about your "generic method to stop an action sequence" you can't pause a sequence of actions for example by settings it's speed to 0, a sequence don't not responding as temporally respond a normal action because it's an action that runs a collection of actions sequentially. An example or explaination about my words could be when you can have an action that report sub-actions / code that calls other scenes / calls to other methods so it's impossible to stop the sequence with the ordinary knowed methods.

    0 讨论(0)
提交回复
热议问题