Game Development Reference
In-Depth Information
[skView presentScene:scene];
}
}
3. Now compile and run the app. You should be able to see the background color
correctly. This will look something similar to following screenshot:
4. Now we have the background color in place, so let's add the gravity to the world.
Open GameScene.m and add the following line of code in the end of the
initWithSize method:
self.physicsWorld.gravity = CGVectorMake(0.0f, -0.5f);
This line of code will set the gravity of the world to -0.5, which means all the
physics objects will experience a force towards the ground in the game scene.
5. Now we have applied some gravitational force to make the objects pulled towards
the ground. So it's important to make some boundary to the world, which will
hold all the objects of the world and prevent them from going off the screen. Add
the following line of code to add the invisible boundary around the screen to hold
the physics objects:
Search WWH ::




Custom Search