HTML and CSS Reference
In-Depth Information
var player = stage.insert(new Q.Player({ x:100, y:0, z:3 }));
stage.insert(new Q.Enemy({ x:400, y:0, z:3 }));
stage.insert(new Q.Enemy({ x:600, y:0, z:3 }));
stage.insert(new Q.Enemy({ x:1200, y:100, z:3 }));
stage.insert(new Q.Enemy({ x:1600, y:0, z:3 }));
stage.bind('reset',function() {
}, { sort: true }));
'background-wall.png',levelFile],function() {
Q.animations('player', {
run_right: { frames: _.range(7,-1,-1), rate: 1/15},
run_left: { frames: _.range(19,11,-1), rate:1/15 },
fire_right: { frames: [9,10,10], next: 'stand_right', rate: 1/30
fire_left: { frames: [20,21,21], next: 'stand_left', rate: 1/30 },
stand_right: { frames: [8], rate: 1/5 },
stand_left: { frames: [20], rate: 1/5 },
fall_right: { frames: [2], loop: false },
fall_left: { frames: [14], loop: false }
Q.animations('blob', {
run_right: { frames: _.range(0,2), rate: 1/5 },
run_left: { frames: _.range(2,4), rate: 1/5 }
The primary change is the addition of the levelFile variable, which stores the name of the level file
loaded into the editor. This can be changed by adding a parameter called level to the end of the URL, for
This would attempt to load data/level2.json instead of the default file data/level.json .
The second change marked here is adding the editor component to the stage. This component isn't written
yet, so running the code currently results in an error, but it will be written in the next section.
The code also binds to a new event on the stage called reset , which is used by the editor to tell the game
to reset itself (which the game does by just reloading the required scene).
Search WWH ::

Custom Search