diff --git a/RtL.min.js b/RtL.min.js index f6990e373e..3f5206acc2 100644 --- a/RtL.min.js +++ b/RtL.min.js @@ -423,16 +423,17 @@ goog.inherits(lime.animation.Spawn,lime.animation.Animation);lime.animation.Spaw robert_the_lifter.Audio.prototype.stopMusic=function(){this.mustPlay=!1;lime.scheduleManager.unschedule(this.playSound,this);this.sound.stop();this.endIn=13E4};lime.Scene=function(){lime.Node.call(this);this.setAnchorPoint(0,0);this.domClassName="lime-scene";this.createDomElement()};goog.inherits(lime.Scene,lime.Node);lime.Scene.prototype.getScene=function(){return this};lime.Scene.prototype.measureContents=function(){return this.getFrame()};robert_the_lifter.PauseMenu=function(a){lime.Layer.call(this);this.game=a;this.game.isPaused=!1;this.extraPauseKey="p";var b=this;this.optionsY=300;this.pauseEvent=function(){a.isPaused=!a.isPaused;a.isPaused?(b.initPauseMenu(),robert_the_lifter.gameScene.appendChild(a.pauseMenu)):(b.removeCurrentMenu(),robert_the_lifter.gameScene.removeChild(a.pauseMenu))};KeyboardJS.on("esc",this.pauseEvent);KeyboardJS.on(this.extraPauseKey,this.pauseEvent);b.blur=(new lime.Sprite).setAnchorPoint(0,0).setPosition(0, 0).setSize(a.width,a.height).setFill(255,255,255,0.5);b.appendChild(b.blur)};goog.inherits(robert_the_lifter.PauseMenu,lime.Layer); robert_the_lifter.PauseMenu.prototype.initPauseMenu=function(){this.removeCurrentMenu();var a=this.game.factoryWidth/2-223,b=new lime.fill.Frame("images/pause_menu.png",0,0,446,226);this.currentMenu=(new lime.Sprite).setAnchorPoint(0,0).setPosition(a,this.optionsY).setFill(b);this.appendChild(this.currentMenu);this.currentMenuEvent=function(b){console.log("Pause Menu clicked");b.event.offsetX>=a&&(b.event.offsetX<=a+446&&b.event.offsetY>=this.optionsY&&b.event.offsetY<=this.optionsY+226)&&(360>=b.event.offsetY? -this.initOptionsMenu():435>=b.event.offsetY?console.log("Credits"):this.unpause())};goog.events.listen(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)}; +this.initOptionsMenu():435>=b.event.offsetY?(this.showCredits(),console.log("Credits")):this.unpause())};goog.events.listen(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)}; robert_the_lifter.PauseMenu.prototype.initOptionsMenu=function(){this.removeCurrentMenu();var a=this.game.factoryWidth/2-223,b=a+225,c=this.optionsY+10,d=this.optionsY+90,e=new lime.fill.Frame("images/options_menu.png",0,0,446,305);this.currentMenu=(new lime.Sprite).setAnchorPoint(0,0).setPosition(a,this.optionsY).setFill(e);this.appendChild(this.currentMenu);this.musicStatus=this.getStatus(this.game.musicSound,b,c);this.appendChild(this.musicStatus);this.sfxStatus=this.getStatus(this.game.sfx,b, d);this.appendChild(this.sfxStatus);this.currentMenuEvent=function(e){e.event.offsetX>=a&&(e.event.offsetX<=a+446&&e.event.offsetY>=this.optionsY&&e.event.offsetY<=this.optionsY+305)&&(360>=e.event.offsetY?(this.game.switchMusicSound(),this.removeChild(this.musicStatus),this.musicStatus=this.getStatus(this.game.musicSound,b,c),this.appendChild(this.musicStatus)):440>=e.event.offsetY?(this.game.switchSFXSound(),this.removeChild(this.sfxStatus),this.sfxStatus=this.getStatus(this.game.sfx,b,d),this.appendChild(this.sfxStatus)): -515>=e.event.offsetY?this.bindingVisible?this.hideKeyBindingMenu():this.showKeyBindingMenu():this.initPauseMenu())};goog.events.listen(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)}; +515>=e.event.offsetY?this.bindingVisible?this.hideKeyBindingMenu():this.showKeyBindingMenu():this.initPauseMenu())};goog.events.listen(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)};robert_the_lifter.PauseMenu.prototype.hideCredits=function(){this.removeChild(this.creditSprite);goog.events.unlisten(this.game.pauseMenu,["mousedown","touchstart"],this.clickToCloseCreditEvent)}; +robert_the_lifter.PauseMenu.prototype.showCredits=function(){this.removeCurrentMenu();var a=this.game.factoryWidth/2-330.5,b=new lime.fill.Frame("images/credits_menu.png",0,0,661,900);this.creditSprite=(new lime.Sprite).setAnchorPoint(0,0).setPosition(a,0).setFill(b);this.appendChild(this.creditSprite);var c=this;this.clickToCloseCreditEvent=function(){c.hideCredits();c.initPauseMenu()};goog.events.listen(this.creditSprite,["mousedown","touchstart"],this.clickToCloseCreditEvent)}; robert_the_lifter.PauseMenu.prototype.showKeyBindingMenu=function(){function a(){this.focus()}this.bindingVisible=!0;document.getElementById("options_wrapper").className="";document.getElementById("options_left_key").value=this.game.turnLeftKey;document.getElementById("options_right_key").value=this.game.turnRightKey;document.getElementById("options_forward_key").value=this.game.forwardKey;document.getElementById("options_backward_key").value=this.game.backwardKey;document.getElementById("options_grab_key").value= this.game.grabKey;document.getElementById("options_pause_key").value=this.extraPauseKey;document.getElementById("options_left_key").onclick=a;document.getElementById("options_right_key").onclick=a;document.getElementById("options_forward_key").onclick=a;document.getElementById("options_backward_key").onclick=a;document.getElementById("options_grab_key").onclick=a;document.getElementById("options_pause_key").onclick=a;this.keyBindingEvent=function(a){116===a.event.keyCode?document.location.reload(!0): 27!==a.event.keyCode&&(document.activeElement.value=window.map[a.event.keyCode][0])};goog.events.listen(this.game.pauseMenu,goog.events.EventType.KEYDOWN,this.keyBindingEvent)}; robert_the_lifter.PauseMenu.prototype.hideKeyBindingMenu=function(){this.bindingVisible=!1;this.game.bindKeys(document.getElementById("options_left_key").value,document.getElementById("options_right_key").value,document.getElementById("options_forward_key").value,document.getElementById("options_backward_key").value,document.getElementById("options_grab_key").value);var a=document.getElementById("options_pause_key").value;""!==a&&(KeyboardJS.clear(this.extraPauseKey),this.extraPauseKey=a,KeyboardJS.on(this.extraPauseKey, this.pauseEvent));"undefined"!=typeof this.keyBindingEvent&&goog.events.unlisten(this.game.pauseMenu,goog.events.EventType.KEYDOWN,this.keyBindingEvent);document.getElementById("options_wrapper").className="hide"}; -robert_the_lifter.PauseMenu.prototype.removeCurrentMenu=function(){this.currentMenu&&this.removeChild(this.currentMenu);this.musicStatus&&this.removeChild(this.musicStatus);this.sfxStatus&&this.removeChild(this.sfxStatus);this.hideKeyBindingMenu();goog.events.unlisten(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)}; +robert_the_lifter.PauseMenu.prototype.removeCurrentMenu=function(){this.currentMenu&&this.removeChild(this.currentMenu);this.musicStatus&&this.removeChild(this.musicStatus);this.sfxStatus&&this.removeChild(this.sfxStatus);this.hideCredits();this.hideKeyBindingMenu();goog.events.unlisten(this.game.pauseMenu,["mousedown","touchstart"],this.currentMenuEvent)}; robert_the_lifter.PauseMenu.prototype.getStatus=function(a,b,c){var d="images/off_status.png";a&&(d="images/on_status.png");a=new lime.fill.Frame(d,0,0,167,37);return(new lime.Sprite).setAnchorPoint(0,0).setPosition(b,c).setFill(a)};robert_the_lifter.PauseMenu.prototype.unpause=function(){this.removeCurrentMenu();this.game.isPaused=!1;robert_the_lifter.gameScene.removeChild(this.game.pauseMenu)};lime.animation.ScaleTo=function(a,b){lime.animation.Animation.call(this);this.scale_=1==arguments.length&&goog.isNumber(a)?new goog.math.Vec2(a,a):2==arguments.length?new goog.math.Vec2(arguments[0],arguments[1]):a};goog.inherits(lime.animation.ScaleTo,lime.animation.Animation);lime.animation.ScaleTo.prototype.scope="scale"; lime.animation.ScaleTo.prototype.makeTargetProp=function(a){var b=a.getScale(),c=new goog.math.Vec2(this.scale_.x-b.x,this.scale_.y-b.y);this.useTransitions()&&(a.addTransition(lime.Transition.SCALE,new goog.math.Vec2(b.x+c.x,b.y+c.y),this.duration_,this.getEasing()),a.setDirty(lime.Dirty.SCALE));return{startScale:b,delta:c}};lime.animation.ScaleTo.prototype.update=function(a,b){if(0!=this.status_){var c=this.getTargetProp(b);b.setScale(c.startScale.x+c.delta.x*a,c.startScale.y+c.delta.y*a)}}; lime.animation.ScaleTo.prototype.clearTransition=function(a){this.useTransitions()&&(a.clearTransition(lime.Transition.SCALE),a.setDirty(lime.Dirty.SCALE))};lime.audio={};lime.audio.Audio=function(a){a&&goog.isFunction(a.data)&&(a=a.data());this.playing_=this.loaded_=!1;this.baseElement=document.createElement("audio");this.baseElement.preload=!0;this.baseElement.loop=!1;goog.userAgent.GECKO&&/\.mp3$/.test(a)&&(a=a.replace(/\.mp3$/,".ogg"));this.baseElement.src=a;this.baseElement.load();this.loadInterval=setInterval(goog.bind(this.loadHandler_,this),10);this.loaded_=!1}; @@ -563,10 +564,10 @@ document.body&&(this.overflowStyle_&&goog.style.uninstallStyles(this.overflowSty lime.Director.prototype.makeMobileWebAppCapable=function(){var a=document.createElement("meta");a.name="apple-mobile-web-app-capable";a.content="yes";document.getElementsByTagName("head").item(0).appendChild(a);a=document.createElement("meta");a.name="apple-mobile-web-app-status-bar-style";a.content="black";document.getElementsByTagName("head").item(0).appendChild(a);a=!1;goog.isDef(localStorage)&&(a=localStorage.getItem("_lime_visited"));/(ipod|iphone|ipad)/i.test(navigator.userAgent)&&(!window.navigator.standalone&& COMPILED&&!a&&this.domElement.parentNode==document.body)&&(alert("Please install this page as a web app by clicking Share + Add to home screen."),goog.isDef(localStorage)&&localStorage.setItem("_lime_visited",!0))};lime.Director.prototype.updateDomOffset_=function(){this.domOffset=goog.style.getPageOffset(this.domElement.parentNode)}; lime.Director.prototype.keyUpHandler_=function(a){a.altKey&&"d"==String.fromCharCode(a.keyCode).toLowerCase()&&(this.debugModeOn_?(goog.style.uninstallStyles(this.debugModeOn_),this.debugModeOn_=null):this.debugModeOn_=goog.style.installStyles(".lime-scene div,.lime-scene img,.lime-scene canvas{border: 1px solid #c00;}"),a.stopPropagation(),a.preventDefault())};lime.Director.prototype.hitTest=function(a){a&&a.screenPosition&&(a.position=this.screenToLocal(a.screenPosition));return!0};robert_the_lifter.Director={}; -robert_the_lifter.start=function(){new lime.fill.Frame("images/pause_menu.png",0,0,446,226);new lime.fill.Frame("images/options_menu.png",0,0,446,305);-1q&&(q=n.getPosition().x+n.measureText().width+15);n=(new lime.Label(c[i].score)).setPosition(q,g).setAnchorPoint(0,0).setFontSize(20);b.appendChild(n);g+=1.1*n.measureText().height}}else i= (new lime.Label("Your browser does not support HTML5 Local Storage.")).setPosition(525,375).setAnchorPoint(0,0).setFontSize(20),b.appendChild(i)};document.getElementById("game").appendChild(f);this.gameScene.appendChild(b)};this.buildWalls=function(){var d=new lime.fill.Frame("images/wall.png",0,0,a.tileWidth,a.wallWidth),e=new lime.fill.Frame("images/wall.png",a.tileWidth,0,a.wallWidth,a.wallWidth),f=(a.factoryNbTileWidth+a.rightAreaTileWidth)*a.tileWidth+a.wallWidth,g=(new lime.Sprite).setAnchorPoint(0, 0).setPosition(f,a.factoryY-a.wallWidth).setSize(a.wallWidth,a.wallWidth).setFill(e);c.appendChild(g);g=(new lime.Sprite).setAnchorPoint(0,0).setPosition(0,a.parkingHeight*a.tileHeight+a.truckParkingY+a.wallWidth).setRotation(90).setSize(a.wallWidth,a.wallWidth).setFill(e);c.appendChild(g);g=(new lime.Sprite).setAnchorPoint(0,0).setPosition(f+a.wallWidth,a.factoryHeight+a.factoryY).setRotation(270).setSize(a.wallWidth,a.wallWidth).setFill(e);c.appendChild(g);e=(new lime.Sprite).setAnchorPoint(0,0).setPosition(a.wallWidth, diff --git a/pauseMenu.js b/pauseMenu.js index cf10f8f764..a8a54302c2 100644 --- a/pauseMenu.js +++ b/pauseMenu.js @@ -69,6 +69,7 @@ robert_the_lifter.PauseMenu.prototype.initPauseMenu = function() { if (e.event.offsetY <= 360) { this.initOptionsMenu(); } else if (e.event.offsetY <= 435) { + this.showCredits(); console.log("Credits"); } else { this.unpause(); @@ -128,7 +129,35 @@ robert_the_lifter.PauseMenu.prototype.initOptionsMenu = function() { } } } - goog.events.listen(this.game.pauseMenu,['mousedown','touchstart'], this.currentMenuEvent); + goog.events.listen(this.game.pauseMenu, ['mousedown','touchstart'], this.currentMenuEvent); +} + +robert_the_lifter.PauseMenu.prototype.hideCredits = function() { + this.removeChild(this.creditSprite); + goog.events.unlisten(this.game.pauseMenu, ['mousedown','touchstart'], this.clickToCloseCreditEvent); +} + +robert_the_lifter.PauseMenu.prototype.showCredits = function() { + this.removeCurrentMenu(); + var width = 661, + height = 900; + var x = (this.game.factoryWidth / 2) - (width/2); + + var creditTile = new lime.fill.Frame('images/credits_menu.png', 0, 0, width, height); + this.creditSprite = new lime.Sprite() + .setAnchorPoint(0,0) + .setPosition(x, 0) + .setFill(creditTile); + this.appendChild(this.creditSprite); + + var layer = this; + + this.clickToCloseCreditEvent = function() { + layer.hideCredits(); + layer.initPauseMenu(); + } + + goog.events.listen(this.creditSprite, ['mousedown','touchstart'], this.clickToCloseCreditEvent); } robert_the_lifter.PauseMenu.prototype.showKeyBindingMenu = function() { @@ -200,6 +229,7 @@ robert_the_lifter.PauseMenu.prototype.removeCurrentMenu = function() { this.removeChild(this.sfxStatus); } + this.hideCredits(); this.hideKeyBindingMenu(); goog.events.unlisten(this.game.pauseMenu,['mousedown','touchstart'], this.currentMenuEvent); } diff --git a/robert_the_lifter.js b/robert_the_lifter.js index 77c7034ade..791bd595d1 100644 --- a/robert_the_lifter.js +++ b/robert_the_lifter.js @@ -25,6 +25,8 @@ robert_the_lifter.start = function() { // load menu images. new lime.fill.Frame('images/pause_menu.png', 0, 0, 446, 226); new lime.fill.Frame('images/options_menu.png', 0, 0, 446, 305); + new lime.fill.Frame('images/credits_menu.png', 0, 0, 661, 900); + // For chrome, images doesn't load on first hit. We show a warning message. if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {