Alex Pilugin Alex Pilugin - 1 year ago 112
Swift Question

Swift. SpriteKit. Any example of customAction withDuration

Could you provide any example of code how to create and use customAction withDuration. Thanks.

P.s. For whom who add minuses to my question. I wanted to have SKAction "run block with duration" I visited Apple API Reference but found another opportunity with the same purpose "customAction withDuration". I asked this question because I never used it and didn't find any example of use it.

Answer Source

You can try something like this:

let action = SKAction.customAction(withDuration: 1) { (aNode, 0.3) in
    //do whatever you want here

Here, you are creating a variable called action with type SKAction. The duration of the action is 1 second, the node that you are using is called aNode, and the block is occurring 0.3 seconds in to the action.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download