Before we add any other objects, we need to prepare the scene to use physics.
Once again, I have created a new project for this chapter. You know the standard operating procedure by now. So, create a new project and make the necessary changes to the project.
MainScene.h file, we will add a new variable of the
CCPhysicsNode type named
_physicsWorld. All the physics objects that we create in a game must be added to this henceforth. We will run the following:
Next, in the
init function, we will add the following:
winSize = [[CCDirector sharedDirector]viewSize]; CGPoint center = CGPointMake(winSize.width/2, winSize.height/2); self.contentSize = winSize; CCSprite* ...