Time for action – fixing the hunter movement

The good thing that comes from the fact that physics simulation and rendering are independent is that we can create physics bodies with just a few lines of code without any images, using just the CCNode class.

In this section, we're going to add the addBoundaries method, which will add two invisible physics bodies to the sides of the screen so that the hunter doesn't fall off the screen. In addition to this, we're going to adjust the friction of the hunter's physics body so that he doesn't slide too much.

  1. Open the PhysicsScene.m file and add the addBoundaries method, as shown in the following code:
    -(void)addBoundaries { CGSize viewSize = [CCDirector sharedDirector].viewSize; CGRect boundRect = CGRectMake(0, ...

Get Learning iPhone Game Development with Cocos2D 3.0 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.