Game Development Reference
In-Depth Information
}
6. Now, add the declaration of both the methods in the
Player.h
file using the
following code:
+ (Player*) playerObject;
- (void) update:(float)deltaTime;
7. Now, open your
GameScene.m
file and add the following code right after your
initWithSize
method:
- (Player *)createPlayer
{
Player *plyr = [Player playerObject];
[self addChild:plyr];
return plyr;
}
8. Now, add the
touchesBegan
method just after the
createPlayer
method.
This method will give you all the touch events.
9. So, nothing happened till now. Let's make the game work for the first state. Now,
add the following code:
Player *newPlayer = [self createPlayer];
newPlayer.position = [touch locationInNode:self];
The final file should look something similar to the following screenshot: