HTML and CSS Reference
In-Depth Information
Clearing all bodies to start the game all over
In future developments, we may need to clear the world and start the game all over. We can
use the following method to clear all the bodies in the Box2D world:
physics.clearWorld = function() {
var body = this.world.GetBodyList();
while (body) {
var sprite = body.GetUserData();
if (sprite) {
sprite.parent.removeChild(sprite);
}
var b = body;
body = body.GetNext();
this.world.DestroyBody(b);
}
};
Mission accomplished
We created a physical game in this project. The player is presented with a level selecion
screen. Then, he/she needs to try his/her best to shoot the ball into the hoop. The following
screenshot shows each state of the game:
 
Search WWH ::




Custom Search