O'Reilly logo

iOS Game Development By Example by Samanyu Chopra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating actions

There are various types of actions which can be applied on a node to make it behave differently, now we are going to study about most of them in detail.

Moving nodes using actions

The SKAction class provides various action methods for moving nodes on a scene. They are as follows:

  • func moveByX( x: CGFloat, y : CGFloat, duration sec: NSTimeInterval): This will move the node to its new position. Here, Delta of x, Delta of y, and duration in seconds are passed as parameters.
  • func moveBy( delta: CGVector, duration sec: NSTimeInterval): This will move the node relative to its current position. Here, Delta vector pointing to a new position and duration in seconds are passed as parameters.
  • moveTo(location: CGPoint, duration sec: NSTimeInterval) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required