Game Development Reference
In-Depth Information
Figure 14-17. The messaging in the level complete screen
After the messaging, an instance of the MagicShop class is added and positioned to the bottom of the screen. This
class will be built in the next section, “Creating the Magic Shop.” Finally, a button sprite is added to the bottom of the
screen, which will move the player on to the level select screen when clicked.
Creating the Magic Shop
As previously mentioned, the magic shop is completely self-contained. It's added to the LevelComplete class, but will
handle all transactions with local storage within itself. Listing 14-44 shows the entire MagicShop class.
Listing 14-44. MagicShop.js - The MagicShop Class Allows the Player to Purchase Items for Future Battles
(function () {
window.game = window.game || {}
function MagicShop() {
this.initialize();
}
var p = MagicShop.prototype = new createjs.Container();
p.Container_initialize = p.initialize;
p.coinsTxt = null;
p.totalCoins = null;
p.magicData = null;
 
Search WWH ::




Custom Search