(function() { "use strict"; var EndScene = function() { this.initialize(); } var p = EndScene.prototype = new creatine.Scene(); p.Scene_initialize = p.initialize; p.initialize = function() { this.Scene_initialize(); // var background = new createjs.Shape(); // background.graphics.beginFill('#444444'); // background.graphics.drawRect(0, 0, canvas.width, canvas.height); // background.alpha = 0.8; // this.layer_background.addChild(background); var w = 420; var h = 320; var infobox = new createjs.Shape(); infobox.graphics.beginFill(SCREEN_TEXT_DARKCOLOR); infobox.graphics.drawRoundRect(0, 0, w, h, 25); infobox.graphics.beginFill(SCREEN_TEXT_LIGHTCOLOR); infobox.graphics.drawRoundRect(2, 2, w-4, h-4, 25); infobox.regX = w/2; infobox.regY = h/2; infobox.x = canvas.width/2; infobox.y = canvas.height/2; this.addChild(infobox); var score = "Score: "+paddingString(registry.levelScore, "000000"); var txtScore = new createjs.Text(score, '48px montserrat', SCREEN_TEXT_DARKCOLOR); this.addChild(txtScore); var score = "Record: "+paddingString(localStorage['btsHighScore'], "000000"); if (registry.levelScore > localStorage['btsHighScore']) { localStorage['btsHighScore'] = registry.levelScore; score = "New Record!" } var txtBestscore = new createjs.Text(score, '32px montserrat', SCREEN_TEXT_DARKCOLOR); this.addChild(txtBestscore); this.buttonReplay = new createjs.Bitmap(loader.getResult('button_replay')); this.addChild(this.buttonReplay); this.buttonBack = new createjs.Bitmap(loader.getResult('button_back')); this.addChild(this.buttonBack); var area = {x:infobox.x-w/2, y:infobox.y-h/2, width:w, height:h}; var vbox = new creatine.BoxSizer(creatine.VERTICAL, area); vbox.add({}, 1, 0); vbox.add(txtScore, 1, 0, creatine.CENTER); vbox.add(txtBestscore, 1, 0, creatine.CENTER); vbox.add({}, 1, 0); var hbox = new creatine.BoxSizer(creatine.HORIZONTAL, area); hbox.add(this.buttonReplay, 1, 0, creatine.CENTER); hbox.add(this.buttonBack, 1, 0, creatine.CENTER); vbox.add(hbox, 1, 0); vbox.add({}, 1); vbox.layout(); libs.submitScore(registry.levelScore); this.on('sceneenter', this.onSceneEnter, this); } p.onSceneEnter = function(event) { this.buttonReplay.on('click', this.onButtonReplay, this); this.buttonBack.on('click', this.onButtonBack, this); } p.onButtonReplay = function(event) { this.buttonReplay.removeAllEventListeners('click'); this.buttonBack.removeAllEventListeners('click'); director.clearStack(); director.replace( new LevelScene(), new creatine.transitions.MoveOut( creatine.TOP, null, 800 ) ) } p.onButtonBack = function(event) { this.buttonReplay.removeAllEventListeners('click'); this.buttonBack.removeAllEventListeners('click'); director.clearStack(); director.replace( new MenuScene(), new creatine.transitions.FadeInOut( // creatine.RIGHT, null, 300 ) ) } p.onUpdate = function(event) { } window.EndScene = EndScene; }());