Selecting and destroying world bodies
As the name Totem Destroyer suggests, you should be able to destroy the totem. First, uncomment the previously commented line in order to give back the totem its left foot, and then we are ready to destroy bricks when the player touches/clicks them.
Everything starts with a touch, so we have to manage it by first adding the listener to the game's init
function:
init:function () {
// same as before
cc.eventManager.addListener(touchListener, this);
}
Then create the listener
variable itself:
var touchListener = cc.EventListener.create({ event: cc.EventListener.TOUCH_ONE_BY_ONE, swallowTouches: true, onTouchBegan: function (touch, event) { var worldPoint = new Box2D.Common.Math.b2Vec2(touch.getLocation().x/worldScale,touch.getLocation().y/worldScale); for (var b = world.GetBodyList(); b; b = b.GetNext()) { if (b.GetUserData() != null && b.GetUserData().type=="destroyable") { for(var f = b.GetFixtureList();f; f=f.GetNext...