(function() { "use strict"; var EndBox = function() { this.initialize(); } var p = EndBox.prototype = new creatine.Scene(); p.Scene_initialize = p.initialize; p.initialize = function() { this.Scene_initialize(); this.background = new createjs.Bitmap(loader.getResult('img_boxbg')); this.btnNextLevel = new Button('Next Level'); this.btnRestart = new Button('Restart'); this.btnMenu = new Button('Menu'); // // set layout var area = {x:100, y:100, width:canvas.width-200, height:canvas.height-200} var vbox = new creatine.BoxSizer(creatine.VERTICAL, area); vbox.add({}, 1, 0, creatine.CENTER); vbox.add(this.btnNextLevel, 1, 0, creatine.RIGHT); vbox.add(this.btnRestart, 1, 0, creatine.RIGHT); vbox.add(this.btnMenu, 1, 0, creatine.RIGHT); vbox.add({}, 1, 0, creatine.CENTER); vbox.layout(); this.txtNSheeps = new createjs.Text(registry.sheepEntities.length, '32px sheep', '#333'); this.txtSheeps = new createjs.Text('Sheep(s)', '24px sheep', '#333'); this.txtTime = new createjs.Text((''+registry.time).toTime(), '28px sheep', '#333'); area = {x:66, y:100, width:333, height:canvas.height-200} vbox = new creatine.BoxSizer(creatine.VERTICAL, area); vbox.add({}, 6, 0, creatine.CENTER); vbox.add(this.txtNSheeps, 1, 0, creatine.CENTER); vbox.add(this.txtSheeps, 1, 0, creatine.CENTER); vbox.add({}, 2, 0, creatine.CENTER); vbox.add(this.txtTime, 1, 0, creatine.CENTER); vbox.add({}, 6, 0, creatine.CENTER); vbox.layout(); // add objects to scene this.addChild(this.background); this.addChild(this.btnNextLevel); this.addChild(this.btnRestart); this.addChild(this.txtNSheeps); this.addChild(this.txtSheeps); this.addChild(this.txtTime); this.addChild(this.btnMenu); // register events this.on('sceneenter', this.onSceneEnter); this.on('sceneresume', this.onSceneResume); this.on('scenepause', this.onScenePause); } p.registerEvents = function(event) { this.btnNextLevel.on('click', this.onButtonNextLevel, this); this.btnRestart.on('click', this.onButtonRestart, this); this.btnMenu.on('click', this.onButtonMenu, this); } p.unregisterEvents = function(event) { this.btnNextLevel.removeAllEventListeners('click'); this.btnRestart.removeAllEventListeners('click'); this.btnMenu.removeAllEventListeners('click'); } p.onUpdate = function(event) { } p.onSceneEnter = function(event) { this.registerEvents(); } p.onSceneResume = function(event) { this.registerEvents(); } p.onScenePause = function(event) { this.unregisterEvents(); } p.onButtonNextLevel = function(event) { registry.currentLevel++; if (!LEVELS[registry.currentLevel]) { director.clearStack(); director.replace( new SelectLevelScene(), new creatine.transitions.MoveOut( creatine.LEFT, null, 200 ) ) } else { director.clearStack(); director.replace( new LevelScene(LEVELS[registry.currentLevel]), new creatine.transitions.MoveOut( creatine.LEFT, null, 200 ) ) } } p.onButtonRestart = function(event) { director.clearStack(); director.replace( new LevelScene(LEVELS[registry.currentLevel]), new creatine.transitions.MoveOut( creatine.LEFT, null, 200 ) ) } p.onButtonMenu = function(event) { director.clearStack(); director.replace( new MenuScene(), new creatine.transitions.Scroll( creatine.RIGHT, null, 200 ) ) } window.EndBox = EndBox; }());