Character movement
Moving a character around a level can be trickier than you might expect. In this recipe, we will lay out the basics of 2D side scrolling character movement.
Getting ready
Please refer to the project RecipeCollection02 for full working code of this recipe. Also note that some of the following code has been omitted for brevity.
How to do it...
Execute the following code:
@implementation SideScrollerRecipe -(void) step:(ccTime)delta { [super step:delta]; //Apply gunman running direction if(dPad.direction == DPAD_LEFT || dPad.direction == DPAD_UP_LEFT || dPad.direction == DPAD_DOWN_LEFT){ gunmanDirection = DPAD_LEFT; gunman.body->ApplyForce(b2Vec2(-35.0f,0), ...
Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.