Creating a simulated physics world
Our first task is to create a simulated physics world and put two objects inside it.
Prepare for lift off
In the index.html
file, the core part is the game
section. We have two canvas
elements in this game. The debug-canvas
element is for the Box2D engine and canvas
is for the CreateJS library:
<section id="game" class="row"> <canvas id="debug-canvas" width="480" height="360"></canvas> <canvas id="canvas" width="480" height="360"></canvas> </section>
We prepare a dedicated file for all the physics-related logic. We prepare the physics.js
file with the following code:
;(function(game, cjs, b2d){ // code here later }).call(this, game, createjs, Box2D);
Engage thrusters
The following steps create the physics world as the foundation of the game:
- The Box2D classes are put in different modules. We will need to reference some common classes...