Configuring the physics space
Look at the heading. It says Configuring the physics space. I used space rather than world because Chipmunk2D calls space what Box2D calls world.
Both world and space represent the same thing: the place where physics-driven things happen.
Although Chipmunk2D calls it space, we will continue to use a variable called world to keep as much similarity with Box2D code as we can. This is the best way for you to see the similarities and differences between the two engines.
Change the init
function in game declaration as follows:
init:function () { this._super(); var backgroundLayer = cc.LayerGradient.create(cc.color(0xdf,0x9f,0x83,255), cc.color(0xfa,0xf7,0x9f,255)); this.addChild(backgroundLayer); world = new cp.Space(); world.gravity = cp.v(0, -100); this.addBody(240,10,480,20,false,"assets/ground.png","ground"); this.addBody(204,32,24,24,true,"assets/brick1x1.png","destroyable"); this.addBody(276,32,24,24,true,"assets/brick1x1.png","destroyable"); ...