Game Development Reference
In-Depth Information
Preparing the Asset Manager
For this game, you'll be using the same AssetManager class that was used in Space Hero in Chapter 11, updated
appropriately for this game. Listing 14-2 shows the full class, with the necessary assets needed for this application in bold.
Listing 14-2. AssetManager.js - The Complete Asset Mangager Class
(function () {
window.game = window.game || {};
var AssetManager = function () {
this.initialize();
}
var p = AssetManager.prototype = new createjs.EventDispatcher();
p.EventDispatcher_initialize = p.initialize;
//sounds
//graphics
p.GAME_SPRITES = 'game sprites';
p.FONT_SPRITES = 'font sprites';
p.BATTLE_BG = 'game bg';
p.MENU_BG = 'menu bg';
//data
p.GAME_SPRITES_DATA = 'game sprites data';
p.FONT_SHEET_DATA = 'font sheet data';
//events
p.ASSETS_PROGRESS = 'assets progress';
p.ASSETS_COMPLETE = 'assets complete';
p.assetsPath = 'assets/';
p.loadManifest = null;
p.queue = null;
p.loadProgress = 0;
p.initialize = function () {
this.EventDispatcher_initialize();
this.loadManifest = [
{id:this.GAME_SPRITES_DATA, src:this.assetsPath +
'spritesheet.json'},
{id:this.GAME_SPRITES, src:this.assetsPath + 'spritesheet.png'},
{id:this.FONT_SHEET_DATA, src:this.assetsPath + 'abc.json'},
{id:this.FONT_SPRITES, src:this.assetsPath + 'abc.png'},
 
Search WWH ::




Custom Search