Game Development Reference
In-Depth Information
paddle.visible = true;
messageTxt.visible = true;
gameRunning = true;
messageTxt.text = "press spacebar to pause";
stage.update();
removeBricks();
newLevel();
newLevel();
createjs.Ticker.setPaused(false);
}
function removeBricks() {
var i, brick;
for (i = 0; i < bricks.length; i++) {
brick = bricks[i];
if (brick.freeLife) {
stage.removeChild(brick.freeLife);
}
stage.removeChild(brick);
}
bricks = [];
}
To reset the game, several of the key game variables are reset to the values they were assigned at the beginning
of the game. All remaining bricks, and their corresponding '1UP' text objects are removed from the stage. Finally, two
new levels are added to the game and the game loop is resumed by unpausing the Ticker .
The Progressive Break-it game is now finished. The complete game code is available in the breakit.js file that
you can find with the other source code for this topic. You can download it from the Source Code/Downloads tab on
the topic's Apress product page ( www.apress.com/9781430263401 ).
Summary
In this chapter, we made a complete game using nothing but code and the magic of EaselJS. All graphics and
messaging were accomplished without loading in a single graphical asset, and by utilizing a game loop we were
able to create a game that involves constant movement. We even took advantage of TweenJS by using it for one-off
animations. Player control was made possible by listening for keyboard events, and assigning them to move the
paddle and pause the game. Simple collision detection techniques were also introduced.
With some key game and drawing techniques now in your arsenal, it's time to start adding much more polish to
your games. The drawing API in EaselJS can be extremely efficient and easy to use, but your graphics really need some
serious upgrading. Loading bitmaps and managing groups of graphics by using containers will be covered in the next
chapter. If you're ready, let's start making your games look a lot more professional.
 
Search WWH ::




Custom Search