function CMenu(){ var _pStartPosPlay; var _pStartPosChallenge; var _pStartPosAudio; var _pStartPosInfo; var _pStartPosFullscreen; var _oBg; var _oButPlay; var _oButPlayChallenge; var _oAudioToggle; var _oFade; var _oButInfo; var _oButFullscreen; var _fRequestFullScreen = null; var _fCancelFullScreen = null; this._init = function(){ _oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_menu')); s_oStage.addChild(_oBg); _pStartPosPlay = {x:(CANVAS_WIDTH/2),y:CANVAS_HEIGHT -70}; var oSprite = s_oSpriteLibrary.getSprite('but_play'); _oButPlay = new CTextButton(_pStartPosPlay.x,_pStartPosPlay.y,oSprite,TEXT_PLAY,FONT_GAME,"#ffffff",30,s_oStage); _oButPlay.addEventListener(ON_MOUSE_UP, this._onButPlay, this, false); //_pStartPosChallenge = {x:(CANVAS_WIDTH/2 + 170),y:CANVAS_HEIGHT -70}; //_oButPlayChallenge = new CTextButton(_pStartPosChallenge.x,_pStartPosChallenge.y,oSprite,TEXT_PLAYCHALLENGE,FONT_GAME,"#ffffff",30,s_oStage); //_oButPlayChallenge.addEventListener(ON_MOUSE_UP, this._onButPlayChallenge, this); if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){ var oSprite = s_oSpriteLibrary.getSprite('audio_icon'); _pStartPosAudio = {x: CANVAS_WIDTH - (oSprite.width/4) - 10, y: (oSprite.height/2) + 10}; _oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_oStage); _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this); } if(SHOW_CREDITS){ var oSprite = s_oSpriteLibrary.getSprite('but_credits'); _pStartPosInfo = {x: (oSprite.height/2) + 10, y: (oSprite.height/2) + 10}; _oButInfo = new CGfxButton(_pStartPosInfo.x,_pStartPosInfo.y,oSprite,s_oStage); _oButInfo.addEventListener(ON_MOUSE_UP, this._onCredits, this); oSprite = s_oSpriteLibrary.getSprite('but_fullscreen'); _pStartPosFullscreen = {x: _pStartPosInfo.x + (oSprite.width / 2) + 10, y: _pStartPosInfo.y}; }else{ oSprite = s_oSpriteLibrary.getSprite('but_fullscreen'); _pStartPosFullscreen = {x: (oSprite.width/2) + 10, y: (oSprite.height/2) + 10}; } var doc = window.document; var docEl = doc.documentElement; _fRequestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen; _fCancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen; if(ENABLE_FULLSCREEN === false){ _fRequestFullScreen = false; } if (_fRequestFullScreen && screenfull.enabled){ _oButFullscreen = new CToggle(_pStartPosFullscreen.x,_pStartPosFullscreen.y,oSprite,s_bFullscreen,s_oStage); _oButFullscreen.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this); } _oFade = new createjs.Shape(); _oFade.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT); s_oStage.addChild(_oFade); createjs.Tween.get(_oFade).to({alpha:0}, 1000).call(function(){_oFade.visible = false;}); this.refreshButtonPos (s_iOffsetX,s_iOffsetY); }; this.unload = function(){ _oButPlay.unload(); _oButPlay = null; if(SHOW_CREDITS){ _oButInfo.unload(); } if (_fRequestFullScreen && screenfull.enabled){ _oButFullscreen.unload(); } //_oButPlayChallenge.unload(); //_oButPlayChallenge = null; if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){ _oAudioToggle.unload(); _oAudioToggle = null; } s_oStage.removeAllChildren(); s_oMenu = null; }; this.refreshButtonPos = function(iNewX,iNewY){ if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){ _oAudioToggle.setPosition(_pStartPosAudio.x - iNewX,iNewY + _pStartPosAudio.y); } if (_fRequestFullScreen && screenfull.enabled){ _oButFullscreen.setPosition(_pStartPosFullscreen.x + s_iOffsetX,_pStartPosFullscreen.y + s_iOffsetY); } _oButPlay.setPosition(_pStartPosPlay.x,_pStartPosPlay.y - iNewY); //_oButPlayChallenge.setPosition(_pStartPosChallenge.x,_pStartPosChallenge.y - iNewY); if(SHOW_CREDITS){ _oButInfo.setPosition(_pStartPosInfo.x + iNewX,iNewY + _pStartPosInfo.y); } }; this._onButPlay = function(){ this.unload(); if (isIOS() && s_oSoundTrack === null) { s_oSoundTrack = playSound("soundtrack",1,true); } s_oMain.gotoGame(false); $(s_oMain).trigger("start_session"); }; this._onButPlayChallenge = function(){ this.unload(); if (isIOS() && s_oSoundTrack === null) { s_oSoundTrack = playSound("soundtrack",1,true); } s_oMain.gotoGame(true); $(s_oMain).trigger("start_session"); }; this._onCredits = function(){ new CCreditsPanel(); }; this._onAudioToggle = function(){ Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive; }; this.resetFullscreenBut = function(){ if (_fRequestFullScreen && screenfull.enabled){ _oButFullscreen.setActive(s_bFullscreen); } }; this._onFullscreenRelease = function(){ if(s_bFullscreen) { _fCancelFullScreen.call(window.document); }else{ _fRequestFullScreen.call(window.document.documentElement); } sizeHandler(); }; s_oMenu = this; this._init(); } var s_oMenu = null;