Search code examples
swiftsknode

How to move a node for a given time?


I wonder how to animate a node to which I assign a few seconds until next action takes place.

For example, if a button is pressed, a node begins to move for three seconds, and after the three seconds pass away, a picture or text appears on the screen.

Should I use NSTimer and NSTimerInterval?


Solution

  • Try to use this fairly simple approach that will help you to manage animation. This animation will take 3 seconds and at the end it will execute a completion handler.

        UIView.animateWithDuration(3.0, animations: { () -> Void in
           //animate object here
        }) { (state: Bool) -> Void in
           // hide animated object here
        }