O'Reilly logo

Mastering iOS Game Development by Miguel DeQuadros

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

Gravity – player movement

For now, import the Player images (in the sprites.atlas file) I have provided in the resources section of this book. Unless you have your own! Then by all means use yours.

Let's go back to our GameLevelScene.m file and import yet another file. This time, it will be #import "Player.h". Then, after the @interface section that we added earlier, we are going to add another property similar to the map property we just added: @property (nonatomic, strong) Player *player1. I used player1 because we will be adding in some multiplayer features later!

Then again, inside the initWithSize function we will add the following code:

self.player = [[Player alloc] initWithImageNamed:@"P1Idle"]; self.player.position = (CGPointMake(100, 50); ...

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