O'Reilly logo

iOS 7 Game Development by Dmitry Volevodz

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

Moving the character with actions

Let's discover how we can add simple player movements to our game, for example, jumping. One of the ways to handle this could be by creating a new action that will move the character up by a certain amount of pixels and then move the character down. Let's try this out.

Remove everything from the touchesBegan: method in ERGMyScene.m. It should look like this:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // we are creating action to move the node that runs it by vector // of x and y components with duration in seconds SKAction *moveUp = [SKAction moveBy:CGVectorMake(0, 100) duration:0.8]; // same as before, but it is opposite vector to go down, and it is a bit // faster, since gravity accelerates ...

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