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 ofx
, Delta ofy
, 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)
: This will move the node to a new position. Location of the new position and duration in seconds are passed as parameters. Here location is aCGpoint
value whose default value is(0,0)
.func moveToX( x: CGFloat, duration sec: NSTimeInterval...