var CRENDER_DEBUG=!1;"undefined"==typeof window.console&&(window.console={log:function(){}});window.Utils||(window.Utils={});var Utils=Utils;Utils.detectMobileBrowser=function(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)}; Utils.getTouchStartEvent=function(){return Utils.isWindowsPhone()?"mspointerdown":"touchstart"};Utils.getTouchMoveEvent=function(){return Utils.isWindowsPhone()?"mspointermove":"touchmove"};Utils.getTouchEndEvent=function(){return Utils.isWindowsPhone()?"mspointerup":"touchend"};Utils.touchScreen=Utils.detectMobileBrowser();Utils.globalScale=1;Utils.globalPixelScale=1;Utils.isWindowHidden=!1;Utils.DOMMainContainerId="main_container";Utils.DOMProgressContainerId="progress_container"; Utils.DOMProgressId="progress";Utils.DOMScreenBackgroundContainerId="screen_background_container";Utils.DOMScreenBackgroundWrapperId="screen_background_wrapper";Utils.DOMScreenBackgroundId="screen_background";Utils.DOMScreenContainerId="screen_container";Utils.DOMScreenWrapperId="screen_wrapper";Utils.DOMScreenId="screen";Utils.DOMP2lContainerId="p2l_container";Utils.DOMP2lId="p2l";Utils.DOMMarkId="mark"; Utils.setCookie=function(a,c){try{window.localStorage.setItem(a,c)}catch(d){var e=new Date;e.setDate(e.getDate()+3650);document.cookie=a+"="+c+"; expires="+e.toUTCString()}};Utils.getCookie=function(a){var c;try{c=window.localStorage.getItem(a)}catch(d){a+="=";c=document.cookie.indexOf(a);if(-1==c)return null;var e=document.cookie.indexOf(";",c+a.length);-1==e&&(e=document.cookie.length);c=unescape(document.cookie.substring(c+a.length,e))}return c}; Utils.bindEvent=function(a,c,d){a.addEventListener?a.addEventListener(c,d,!1):a.attachEvent&&a.attachEvent("on"+c,d)};Utils.unbindEvent=function(a,c,d){a.removeEventListener?a.removeEventListener(c,d,!1):a.detachEvent&&a.detachEvent("on"+c,d)};Utils.getObjectLeft=function(a){var c=a.offsetLeft;a.offsetParent&&(c+=Utils.getObjectLeft(a.offsetParent));return c};Utils.getObjectTop=function(a){var c=a.offsetTop;a.offsetParent&&(c+=Utils.getObjectTop(a.offsetParent));return c}; Utils.parseGet=function(){var a={},c=window.location.toString(),d=window.location.toString().indexOf("?");if(0<=d)for(var c=c.substr(d+1,c.length),d=c.split("&"),e=0;e
";d+='
 
';document.getElementById(Utils.DOMProgressId).innerHTML=d};Utils.hideAddressBarLock=!1;Utils.mobileHideAddressBar=function(){Utils.hideAddressBarLock||window.scrollTo(0,1)}; Utils.mobileCheckIphone4=function(){return Utils.touchScreen&&0<=navigator.userAgent.indexOf("iPhone")&&2==window.devicePixelRatio};Utils.mobileCheckBrokenAndroid=function(){return Utils.touchScreen&&Utils.isAndroid()&&!Utils.isChrome()&&!Utils.isFirefox()};Utils.mobileCheckSlowDevice=function(){return Utils.mobileCheckBrokenAndroid()&&0<=navigator.userAgent.toLowerCase().indexOf("sm-t310")||Utils.touchScreen&&Utils.isAndroid()&&Utils.isFirefox()&&0<=navigator.userAgent.toLowerCase().indexOf("sm-t310")}; Utils.isChrome=function(){var a=!1;0<=navigator.userAgent.toLowerCase().indexOf("chrome")&&(a=!0,Utils.isAndroid()&&22>(parseInt((/Chrome\/([0-9]+)/.exec(navigator.appVersion)||0)[1],10)||0)&&(a=!1));return a};Utils.isAndroid=function(){return 0<=navigator.userAgent.toLowerCase().indexOf("android")};Utils.isIOS=function(){return navigator.userAgent.toLowerCase().match(/(ipad|iphone|ipod)/g)?!0:!1};Utils.isPlayFreeBrowser=function(){return 0<=navigator.userAgent.toLowerCase().indexOf("playfreebrowser")}; Utils.isFirefox=function(){return 0<=navigator.userAgent.toLowerCase().indexOf("firefox")};Utils.isWindowsPhone=function(){return 0<=navigator.userAgent.toLowerCase().indexOf("windows phone")};Utils.disableCorrectPixelRatio=!1; Utils.mobileCorrectPixelRatio=function(){for(var a=document.getElementsByTagName("head")[0].getElementsByTagName("meta"),c=!0,d=null,e="",f=0;fl&&(d=l,c=f[e].scale)}return Utils.getScaleScreenResolution(c,a)};Utils.getScaleScreenResolution=function(a,c){var d=Math.round(320*a),e=Math.round(480*a);return{width:c?e:d,height:c?d:e,scale:a}};Utils.imagesRoot="images";Utils.initialResolution={width:320,height:480,scale:1};Utils.ignoreMobileHeightCorrection=!1; Utils.createLayout=function(a,c,d,e){var f=Utils.globalScale;Utils.initialResolution=c;d=window.innerHeight;document.body.style.overflow="hidden";var g;g=""+('
');g+='
';g=g+"
"+('";g+='";a.innerHTML=g;a=document.createElement("div");a.setAttribute("id",Utils.DOMP2lContainerId);a.setAttribute("align","center");a.setAttribute("style","width: 100%; height: "+d+"px; position: absolute; left: 0px; top: 0px; visibility: hidden; z-index: 1000; background-color: #fff; background-image: url("+Utils.imagesRoot+"/p2l.jpg); background-repeat: no-repeat; background-position: center center");c=document.createElement("img"); c.setAttribute("id",Utils.DOMP2lId);c.width=1;c.height=1;c.style.display="none";a.appendChild(c);document.body.appendChild(a);a=document.createElement("div");a.setAttribute("id",Utils.DOMMarkId);a.style.position="fixed";a.style.right="0px";a.style.bottom="0px";a.style.width="1px";a.style.height="1px";a.style.background="";a.style.zIndex="100000";document.body.appendChild(a);Utils.fitLayoutToScreen()}; Utils.showMainLayoutContent=function(){document.getElementById(Utils.DOMProgressContainerId).style.display="none";document.getElementById(Utils.DOMScreenContainerId).style.display="block";document.getElementById(Utils.DOMScreenBackgroundContainerId).style.display="block"};Utils.preventEvent=function(a){a.preventDefault();a.stopPropagation();a.cancelBubble=!0;return a.returnValue=!1};Utils.touchStartEventDisabled=!1; Utils.preventTouchStart=function(){Utils.touchStartEventDisabled&&Utils.bindEvent(document.body,Utils.getTouchStartEvent(),Utils.preventEvent)};Utils.removePreventTouchStart=function(){Utils.touchStartEventDisabled&&Utils.unbindEvent(document.body,Utils.getTouchStartEvent(),Utils.preventEvent)}; Utils.addMobileListeners=function(a,c){if(c||!navigator.userAgent.match(/(iPad|iPhone|iPod).*CPU.*OS 7_\d/i))Utils.touchStartEventDisabled=!0,Utils.preventTouchStart();Utils.isPlayFreeBrowser()||Utils.bindEvent(window,"scroll",function(a){setTimeout(Utils.mobileHideAddressBar,300)});document.addEventListener(Utils.getVisibiltyProps().visibilityChange,Utils.handleVisibilityChange,!1);setInterval("Utils.checkOrientation("+(a?"true":"false")+")",500);setTimeout(Utils.mobileHideAddressBar,500)}; Utils.handleVisibilityChange=function(){Utils.isWindowHidden=document[Utils.getVisibiltyProps().hidden];Utils.dispatchEvent(Utils.isWindowHidden?"hidewindow":"showwindow")}; Utils.getVisibiltyProps=function(){var a,c;"undefined"!==typeof document.hidden?(a="hidden",c="visibilitychange"):"undefined"!==typeof document.mozHidden?(a="mozHidden",c="mozvisibilitychange"):"undefined"!==typeof document.msHidden?(a="msHidden",c="msvisibilitychange"):"undefined"!==typeof document.webkitHidden&&(a="webkitHidden",c="webkitvisibilitychange");return{hidden:a,visibilityChange:c}};Utils.staticWindowRect=null;Utils.setWindowRect=function(a,c){Utils.staticWindowRect={width:a,height:c}}; Utils.getWindowRect=function(){var a=document.getElementById(Utils.DOMMarkId);return Utils.isAndroid()&&a?{width:window.innerWidth,height:a.offsetTop+1}:{width:window.innerWidth,height:window.innerHeight}};Utils.storeOrient=null;Utils.noCheckOrient=!1; Utils.checkOrientation=function(a){if(Utils.touchScreen&&document.getElementById(Utils.DOMScreenContainerId)&&!Utils.noCheckOrient&&1!=Utils.parseGet().nocheckorient){var c=Utils.getWindowRect(),c=c.width>c.height;Utils.storeOrient!==c&&(Utils.storeOrient=c,c!=a?(Utils.dispatchEvent("lockscreen"),document.getElementById(Utils.DOMP2lContainerId).style.visibility="visible",document.getElementById(Utils.DOMProgressContainerId).style.visibility="hidden",document.getElementById(Utils.DOMScreenBackgroundContainerId).style.display= "none",document.getElementById(Utils.DOMScreenContainerId).style.display="none"):(Utils.dispatchEvent("unlockscreen"),document.getElementById(Utils.DOMP2lContainerId).style.visibility="hidden",document.getElementById(Utils.DOMProgressContainerId).style.visibility="visible",document.getElementById(Utils.DOMScreenBackgroundContainerId).style.display="block",document.getElementById(Utils.DOMScreenContainerId).style.display="block"),setTimeout(Utils.mobileHideAddressBar,900),setTimeout(Utils.fitLayoutToScreen, 1E3))}};Utils.fitLayoutTimer=null;Utils.addFitLayoutListeners=function(){Utils.fitLayoutTimer=setInterval(Utils.fitLayoutToScreen,500)};Utils.removeFitLayoutListeners=function(){clearInterval(Utils.fitLayoutTimer)};Utils.fitLayoutLock=!1;Utils.fitLayoutCorrectHeight=0;Utils.fitLayoutAlign="center";Utils.fitLayoutVerticalAlign="top";Utils.layoutMargin={left:0,right:0,top:0,bottom:0}; Utils.fitLayoutToScreen=function(a){if(!Utils.fitLayoutLock){var c,d,e,f,g;g=Utils.getWindowRect();"object"==typeof a&&a.width||(f=Utils.staticWindowRect?Utils.staticWindowRect:g,d=f.width,e=f.height,e+=Utils.fitLayoutCorrectHeight,e-=Utils.layoutMargin.top,e-=Utils.layoutMargin.bottom,d-=Utils.layoutMargin.left,d-=Utils.layoutMargin.right,a={width:d,height:e});if(c=document.getElementById(Utils.DOMScreenWrapperId)){c.initWidth||(c.initWidth=Utils.initialResolution.width,c.initHeight=Utils.initialResolution.height); d=c.initWidth;e=c.initHeight;var h=1,h=a.width/d,l=a.height/e,h=h=a?1:a*e(a-1)}return e(c)/(e(a)*e(c-a))*Math.pow(d,a)*Math.pow(1-d,c-a)}; Utils.getBezierCurve=function(a,c){"undefined"==typeof c&&(c=.1);var d=[];c/=a.length;for(var e=0;e<1+c;e+=c){1=c?this.endCallback&&this.endCallback(this.loadedImages):(this.processCallback&&this.processCallback(Math.floor(a/c*this.maxProgressVal+this.minProgressVal)),setTimeout(this.wait,50))};function SoundsPreloader(a,c,d){this.sounds=a;this.endCallback=c;this.progressCallback=d;this.minProgressVal=this.loadedCount=0;this.maxProgressVal=100} SoundsPreloader.prototype.isMp3Support=function(){return""!=document.createElement("audio").canPlayType("audio/mpeg")};SoundsPreloader.prototype.isWebAudio=function(){return Boolean(window.AudioMixer)&&AudioMixer.isWebAudioSupport()}; SoundsPreloader.prototype.load=function(a,c,d){a&&(this.sounds=a);c&&(this.endCallback=c);d&&(this.progressCallback=d);if(!this.sounds||1>this.sounds.length||!this.isWebAudio())this.endCallback&&this.endCallback();else{a=this.isMp3Support()?"mp3":"ogg";var e;this.loadedCount=0;var f=this;for(d=0;d=c.sounds.length&&c.endCallback&&c.endCallback()}; function Asset(a,c,d,e,f,g){this.name=a+"";this.src=c+"";this.width=d;this.height=e;this.frames=f;this.layers=g;this.object=this.bitmap=null;this.ready=!(!this.width||!this.height);this.spriteClass=null}Asset.prototype.detectSize=function(){if(!this.bitmap)return!1;try{isNaN(this.width)&&(this.width=this.bitmap.width?parseInt(this.bitmap.width):0),isNaN(this.height)&&(this.height=this.bitmap.height?parseInt(this.bitmap.height):0)}catch(a){CRENDER_DEBUG&&console.log(a)}return!isNaN(this.width)&&!isNaN(this.height)}; Asset.prototype.normalize=function(a){if(!this.ready&&this.detectSize()){if(isNaN(this.frames)||1>this.frames)this.frames=1;if(isNaN(this.layers)||1>this.layers)this.layers=1;this.width=Math.ceil(this.width/this.layers/a);this.height=Math.ceil(this.height/this.frames/a);this.ready=!0}}; function AssetsLibrary(a,c,d){this.path="images";this.scale=1;this.items={};this.bitmaps={};this.loaded=!1;this.onloadprogress=this.onload=null;this.spriteClass=Sprite;this.onLoadHandler=Utils.proxy(this.onLoadHandler,this);this.onLoadProgressHandler=Utils.proxy(this.onLoadProgressHandler,this);this.init(a,c);this.addAssets(d)}AssetsLibrary.prototype.init=function(a,c){"undefined"!=typeof a&&(this.path=a+"");"undefined"!=typeof c&&(this.scale=parseFloat(c),isNaN(this.scale)&&(this.scale=1))}; AssetsLibrary.prototype.load=function(a,c,d,e){this.onload=a;this.onloadprogress=c;a=new ImagesPreloader;c=[];for(var f in this.items)c.push(this.items[f]);"undefined"!=typeof d&&(a.minProgressVal=d);"undefined"!=typeof e&&(a.maxProgressVal=e);a.load(c,this.onLoadHandler,this.onLoadProgressHandler)};AssetsLibrary.prototype.onLoadProgressHandler=function(a){if("function"==typeof this.onloadprogress)this.onloadprogress(a)}; AssetsLibrary.prototype.onLoadHandler=function(a){this.loaded=!0;for(var c in a){var d=this.items[c];d.bitmap=a[c];d.normalize(this.scale)}if("function"==typeof this.onload)this.onload(this.items)};AssetsLibrary.prototype.addAssets=function(a){if("undefined"!=typeof a&&"object"==typeof a)for(var c=0;ca;a++)this.vertices[a].rotate(-this.angle,this.center),this.vertices[a].xthis.AABB[1].x&&(this.AABB[1].x=this.vertices[a].x), this.vertices[a].ythis.AABB[1].y&&(this.AABB[1].y=this.vertices[a].y)};Rectangle.prototype.move=function(a,c){this.center.add(new Vector(a,c));this.refreshVertices()};Rectangle.prototype.rotate=function(a){this.angle+=a;this.refreshVertices()};Rectangle.prototype.hitTestPoint=function(a){a=a.clone();a.normalize(-this.angle,this.center);return Math.abs(a.x)<=this.width/2&&Math.abs(a.y)<=this.height/2}; Rectangle.prototype.hitTestRectangle=function(a){var c=this.clone();a=a.clone();var d,e,f;c.move(-this.center.x,-this.center.y);a.move(-this.center.x,-this.center.y);a.center.rotate(this.angle);c.rotate(-this.angle);a.rotate(-this.angle);d=Math.max(c.AABB[0].x,c.AABB[1].x,a.AABB[0].x,a.AABB[1].x)-Math.min(c.AABB[0].x,c.AABB[1].x,a.AABB[0].x,a.AABB[1].x);e=c.AABB[1].x-c.AABB[0].x;f=a.AABB[1].x-a.AABB[0].x;if(d>e+f)return!1;d=Math.max(c.AABB[0].y,c.AABB[1].y,a.AABB[0].y,a.AABB[1].y)-Math.min(c.AABB[0].y, c.AABB[1].y,a.AABB[0].y,a.AABB[1].y);e=c.AABB[1].y-c.AABB[0].y;f=a.AABB[1].y-a.AABB[0].y;if(d>e+f)return!1;c.move(-a.center.x,-a.center.y);a.move(-a.center.x,-a.center.y);c.center.rotate(a.angle);c.refreshVertices();c.rotate(-a.angle);a.rotate(-a.angle);d=Math.max(c.AABB[0].x,c.AABB[1].x,a.AABB[0].x,a.AABB[1].x)-Math.min(c.AABB[0].x,c.AABB[1].x,a.AABB[0].x,a.AABB[1].x);e=c.AABB[1].x-c.AABB[0].x;f=a.AABB[1].x-a.AABB[0].x;if(d>e+f)return!1;d=Math.max(c.AABB[0].y,c.AABB[1].y,a.AABB[0].y,a.AABB[1].y)- Math.min(c.AABB[0].y,c.AABB[1].y,a.AABB[0].y,a.AABB[1].y);e=c.AABB[1].y-c.AABB[0].y;f=a.AABB[1].y-a.AABB[0].y;return d>e+f?!1:!0}; var EventsManager={addEvent:function(a,c,d){if(a.eventsListeners){for(var e=0;e(a/=e/2)?d/2*a*a*(((f*=1.525)+1)*a-f)+c:d/2*((a-=2)*a*(((f*=1.525)+1)*a+f)+2)+c}},bounce:{easeIn:function(a,c,d,e){return d-Easing.bounce.easeOut(e-a,0,d,e)+c},easeOut:function(a,c,d,e){return(a/=e)<1/2.75?7.5625*d*a*a+c:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+.75)+c:a<2.5/2.75?d*(7.5625*(a-=2.25/ 2.75)*a+.9375)+c:d*(7.5625*(a-=2.625/2.75)*a+.984375)+c},easeInOut:function(a,c,d,e){return a(a/=e/2)?-d/2*(Math.sqrt(1-a*a)-1)+c:d/2*(Math.sqrt(1-(a-=2)*a)+1)+c}},cubic:{easeIn:function(a,c,d,e){return d*(a/=e)*a*a+c},easeOut:function(a,c, d,e){return d*((a=a/e-1)*a*a+1)+c},easeInOut:function(a,c,d,e){return 1>(a/=e/2)?d/2*a*a*a+c:d/2*((a-=2)*a*a+2)+c}},exponential:{easeIn:function(a,c,d,e){return 0==a?c:d*Math.pow(2,10*(a/e-1))+c},easeOut:function(a,c,d,e){return a==e?c+d:d*(-Math.pow(2,-10*a/e)+1)+c},easeInOut:function(a,c,d,e){return 0==a?c:a==e?c+d:1>(a/=e/2)?d/2*Math.pow(2,10*(a-1))+c:d/2*(-Math.pow(2,-10*--a)+2)+c}},linear:{easeIn:function(a,c,d,e){return d*a/e+c},easeOut:function(a,c,d,e){return d*a/e+c},easeInOut:function(a, c,d,e){return d*a/e+c}},quadratic:{easeIn:function(a,c,d,e){return d*(a/=e)*a+c},easeOut:function(a,c,d,e){return-d*(a/=e)*(a-2)+c},easeInOut:function(a,c,d,e){return 1>(a/=e/2)?d/2*a*a+c:-d/2*(--a*(a-2)-1)+c}},quartic:{easeIn:function(a,c,d,e){return d*(a/=e)*a*a*a+c},easeOut:function(a,c,d,e){return-d*((a=a/e-1)*a*a*a-1)+c},easeInOut:function(a,c,d,e){return 1>(a/=e/2)?d/2*a*a*a*a+c:-d/2*((a-=2)*a*a*a-2)+c}},quintic:{easeIn:function(a,c,d,e){return d*(a/=e)*a*a*a*a+c},easeOut:function(a,c,d,e){return d* ((a=a/e-1)*a*a*a*a+1)+c},easeInOut:function(a,c,d,e){return 1>(a/=e/2)?d/2*a*a*a*a*a+c:d/2*((a-=2)*a*a*a*a+2)+c}},sine:{easeIn:function(a,c,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+c},easeOut:function(a,c,d,e){return d*Math.sin(a/e*(Math.PI/2))+c},easeInOut:function(a,c,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+c}},smoothstep:{easeIn:function(a,c,d,e){a=a/e/2;return 2*a*a*(3-2*a)*d+c},easeOut:function(a,c,d,e){a=(a/e+1)/2;return(2*a*a*(3-2*a)-1)*d+c},easeInOut:function(a,c,d,e){a/=e;return a*a*(3- 2*a)*d+c}}}; function Tween(a,c,d,e,f,g){Utils.callSuperConstructor(Tween,this);"object"!=typeof a&&(a=null);if(a){if("undefined"==typeof a[c])throw Error('Trying to tween undefined property "'+c+'"');if(isNaN(a[c]))throw Error("Tweened value can not be "+typeof a[c]);}else if(isNaN(c))throw Error("Tweened value can not be "+typeof c);"function"!=typeof g&&(g=Easing.linear.easeIn);this.obj=a;this.prop=c;this.onfinish=this.onchange=null;this.start=d;this.end=e;this.duration=~~f;this.callback=g;this.playing=!1; this._pos=-1;this.newly=!0;this.eventsListeners=[]}Utils.extend(Tween,EventsProxy);Tween.prototype.play=function(){this.playing=!0;this.tick(0)};Tween.prototype.pause=function(){this.playing=!1};Tween.prototype.rewind=function(){this._pos=-1};Tween.prototype.forward=function(){this._pos=this.duration};Tween.prototype.stop=function(){this.pause();this.rewind()};Tween.prototype.updateValue=function(a){this.obj?this.obj[this.prop]=a:this.prop=a}; Tween.prototype.tick=function(a){if(!this.playing)return!1;a||(a=0);Tween.STEP_TYPE==Tween.STEP_BY_FRAME?this._pos++:this._pos+=a;if(0>this._pos)return!1;if(this._pos>this.duration)return this.finish();a=this.callback;a=a(this._pos,this.start,this.end-this.start,this.duration);this.updateValue(a);this.dispatchEvent("change",{target:this,value:a});return!1}; Tween.prototype.finish=function(){this.stop();this.updateValue(this.end);return!1===this.dispatchEvent("finish",{target:this,value:this.end})?!1:!0};Tween.STEP_BY_FRAME=0;Tween.STEP_BY_TIME=1;Tween.STEP_TYPE=Tween.STEP_BY_FRAME;function DisplayObjectContainer(){Utils.callSuperConstructor(DisplayObjectContainer,this);this.objects=[];this.anchor={x:0,y:0}}Utils.extend(DisplayObjectContainer,EventsProxy);DisplayObjectContainer.prototype.objectsCounter=0;DisplayObjectContainer.prototype.scaleX=1; DisplayObjectContainer.prototype.scaleY=1;DisplayObjectContainer.prototype.opacity=1;DisplayObjectContainer.prototype.x=0;DisplayObjectContainer.prototype.y=0;DisplayObjectContainer.prototype.width=0;DisplayObjectContainer.prototype.height=0;DisplayObjectContainer.prototype.skewX=0;DisplayObjectContainer.prototype.skewY=0;DisplayObjectContainer.prototype.rotation=0;DisplayObjectContainer.prototype.parent=null;DisplayObjectContainer.prototype.hitArea=null; DisplayObjectContainer.prototype.fillColor=null;DisplayObjectContainer.prototype.fillLinearGradient=null;DisplayObjectContainer.prototype.fillRadialGradient=null;DisplayObjectContainer.prototype.fillPattern=null;DisplayObjectContainer.prototype.getAbsoluteRotation=function(){return this.rotation+(this.parent?this.parent.getAbsoluteRotation():0)};DisplayObjectContainer.prototype.getAbsoluteOpacity=function(){return this.opacity*(this.parent?this.parent.getAbsoluteOpacity():1)}; DisplayObjectContainer.prototype.getAbsoluteScaleX=function(){return this.scaleX*(this.parent?this.parent.getAbsoluteScaleX():1)};DisplayObjectContainer.prototype.getAbsoluteScaleY=function(){return this.scaleY*(this.parent?this.parent.getAbsoluteScaleY():1)};DisplayObjectContainer.prototype.getAbsoluteSkewX=function(){return this.skewX+(this.parent?this.parent.getAbsoluteSkewX():0)}; DisplayObjectContainer.prototype.getAbsoluteSkewY=function(){return this.skewY+(this.parent?this.parent.getAbsoluteSkewY():0)};DisplayObjectContainer.prototype.render=function(a,c,d){for(var e=0;ea&&(a=DisplayObjectContainer.ANCHOR_ALIGN_LEFT);0c&&(c=DisplayObjectContainer.ANCHOR_VALIGN_TOP);0a&&(a=this.objects[d].zIndex,c=d);return{index:c,zIndex:a}}; DisplayObjectContainer.prototype.findMinZIndex=function(){for(var a=-1,c=!1,d=0;dc.uid?1:-1:a.zIndex>c.zIndex?1:-1})}; DisplayObjectContainer.prototype.getHitArea=function(){return this.hitArea?this.hitArea:{x:0,y:0,width:this.width,height:this.height}}; DisplayObjectContainer.prototype.hitTest=function(a,c){c||(c=this);if(0==a.getAbsoluteRotation()&&0==c.getAbsoluteRotation()){var d=a.getCenter(),e=c.getCenter(),f=a.width*Math.abs(a.getAbsoluteScaleX()),g=a.height*Math.abs(a.getAbsoluteScaleY()),h=c.width*Math.abs(c.getAbsoluteScaleX()),l=c.height*Math.abs(c.getAbsoluteScaleY()),k=d.x-f/2,d=d.y-g/2,m=e.x-h/2,n=e.y-l/2,p=Math.max(d,n),e=Math.max(k,m),f=Math.min(k+f,m+h),g=Math.min(d+g,n+l)-p;return 0=m&&h+k>=n&&(p=!0):(g=a.getHitAreaRectangle(),g.hitTestPoint(new Vector(m,n))&&(p= !0));p&&e&&(this.stage.buffer.width=this.stage.canvas.width,this.stage.buffer.height=this.stage.canvas.height,this.stage.clearScreen(this.stage.buffer),a.render(this.stage.buffer,a.static,0),c=this.stage.buffer.ctx.getImageData(Math.floor(c*Utils.globalScale),Math.floor(d*Utils.globalScale),1,1),0==c.data[3]&&(p=!1));!p&&f&&a.dragged&&(p=!0);return p}; DisplayObjectContainer.prototype.getObjectsStackByCoord=function(a,c,d,e){for(var f,g=[],h=this.objects.length-1;0<=h;h--)this.objects[h].visible&&(f=this.objects[h],f.objects&&f.objects.length&&(g=g.concat(f.getObjectsStackByCoord(a,c,d,e))),this.hitTestPointObject(f,a,c,d,e)&&g.push(f));return g}; DisplayObjectContainer.prototype.doDrag=function(a,c){for(var d=0;da.indexOf(this))return this.mouseOn=!1,d=this.stage.finalizeMouseCoords(this,c),this.dispatchEvent("mouseout",{target:this,x:d.x,y:d.y})};DisplayObjectContainer.prototype.getMaxZIndexInStack=function(a){for(var c=-1,d=0,e=0;ec&&(c=a[e].zIndex,d=e);return d}; DisplayObjectContainer.prototype.sortStack=function(a,c){return a.sort(function(a,e){a.zIndex==e.zIndex?c?a.uide.uid?1:-1:c?a.zIndexe.zIndex?1:-1})};DisplayObjectContainer.prototype.clear=function(){for(;this.objects.length;)this.removeChild(this.objects[0])}; DisplayObjectContainer.prototype.getFillStyle=function(a){var c=null;if(this.fillLinearGradient){a=a.ctx.createLinearGradient(this.fillLinearGradient.x0*Utils.globalScale,this.fillLinearGradient.y0*Utils.globalScale,this.fillLinearGradient.x1*Utils.globalScale,this.fillLinearGradient.y1*Utils.globalScale);for(c=0;c=d?this.setPosition(a,c):((a=this.addTween("x",a,d,e))&&a.play(),(c=this.addTween("y",c,d,e,f,g))&&c.play());return this};DisplayObject.prototype.moveBy=function(a,c,d,e,f,g){return this.moveTo(this.x+a,this.y+c,d,e,f,g)};DisplayObject.prototype.fadeTo=function(a,c,d,e,f){c=~~c;0>=c?this.opacity=a:(a=this.addTween("opacity",a,c,d,e,f))&&a.play();return this}; DisplayObject.prototype.fadeBy=function(a,c,d,e,f){a=Math.max(0,Math.min(1,this.opacity+a));return this.fadeTo(a,c,d,e,f)};DisplayObject.prototype.rotateTo=function(a,c,d,e,f){c=~~c;0>=c?this.rotation=a:(a=this.addTween("rotation",a,c,d,e,f))&&a.play();return this};DisplayObject.prototype.rotateBy=function(a,c,d,e,f){return this.rotateTo(this.rotation+a,c,d,e,f)};DisplayObject.prototype.skewXTo=function(a,c,d,e,f){c=~~c;0>=c?this.skewX=a:(a=this.addTween("skewX",a,c,d,e,f))&&a.play();return this}; DisplayObject.prototype.skewXBy=function(a,c,d,e,f){return this.skewXTo(this.skewX+a,c,d,e,f)};DisplayObject.prototype.skewYTo=function(a,c,d,e,f){c=~~c;0>=c?this.skewY=a:(a=this.addTween("skewY",a,c,d,e,f))&&a.play();return this};DisplayObject.prototype.skewYBy=function(a,c,d,e,f){return this.skewYTo(this.skewY+a,c,d,e,f)}; DisplayObject.prototype.scaleTo=function(a,c,d,e,f){c=~~c;if(0>=c)this.scaleX=this.scaleY=a;else{var g=this.addTween("scaleX",a,c,d,e,f);g&&g.play();(a=this.addTween("scaleY",a,c,d,g?null:e,g?null:f))&&a.play()}return this};DisplayObject.prototype.setZIndex=function(a){this.zIndex=~~a;this.parent&&this.parent.setChildZIndex(this,this.zIndex)};DisplayObject.prototype.hitTestPoint=function(a,c,d,e,f){return this.stage?this.stage.hitTestPointObject(this,a,c,d,e,f):!1}; DisplayObject.prototype.setRelativePosition=function(a,c,d,e){switch(d){case "right":a=this.stage.screenWidth-a;break;case "left":break;default:a=this.stage.screenWidth/2+a}switch(e){case "bottom":c=this.stage.screenHeight-c;break;case "top":break;default:c=this.stage.screenHeight/2+c}this.setPosition(a,c)}; DisplayObject.prototype.debugDraw=function(){if(this.visible&&this.allowDebugDrawing){var a=this.getAbsolutePosition(),c=this.getCenter(),d=this.getDrawRectangle(),e=this.getAABBRectangle();stage.drawCircle(a.x,a.y,1,1,"rgba(255,0,0,0.9)");stage.drawCircle(c.x,c.y,1,1,"rgba(0,255,0,0.9)");stage.drawLine(a.x,a.y,c.x,c.y,1,"rgba(255,255,255,0.5)");stage.drawPolygon(d.vertices,.5,"rgba(255,0,255,0.5)",1);stage.drawLine(e.vertices[0].x,e.vertices[0].y,e.vertices[2].x,e.vertices[2].y,1,"rgba(255,255,255,0.5)"); stage.drawLine(e.vertices[2].x,e.vertices[0].y,e.vertices[0].x,e.vertices[2].y,1,"rgba(255,255,255,0.5)");stage.drawPolygon(e.vertices,.5,"rgba(255,255,255,0.5)")}};DisplayObject.prototype.fixChildrenParent=function(a){for(a=0;aa.length)throw Error("Invalid parameters");Utils.callSuperConstructor(Graphics.polygon,this);this.points=a;for(var c=Number.MAX_VALUE,d=Number.MAX_VALUE,e=Number.MIN_VALUE,f=Number.MIN_VALUE,g=0;ge&&(e=a[g].x),a[g].y>f&&(f=a[g].y);this.width=e-c;this.height=f-d};Utils.extend(Graphics.polygon,Graphics); Graphics.polygon.prototype.render=function(a,c,d){if(!!this.static==!!c&&0!=this.opacity){this.prepareCanvas(this.getAbsoluteCenter(),a);this.preparePath(a);a.ctx.moveTo(this.points[0].x*Utils.globalScale,this.points[0].y*Utils.globalScale);for(var e=1;e=this.totalFrames&&(this.animated=!1);this.totalLayers=Math.max(1,~~f);this.bitmap=a;this.changeFrameDelay=Sprite.CHANGE_FRAME_DELAY;this.cacheBitmap=Sprite.CACHE_BITMAPS}Utils.extend(Sprite,DisplayObject);Sprite.prototype.animated=!0;Sprite.prototype.animDirection=1;Sprite.prototype.currentFrame=0;Sprite.prototype.totalFrames=1; Sprite.prototype.currentLayer=0;Sprite.prototype.totalLayers=1;Sprite.prototype.bitmap=null;Sprite.prototype.mask=null;Sprite.prototype.isMask=!1;Sprite.prototype.maskParent=null;Sprite.prototype.maskInvert=!1;Sprite.prototype.animStep=0;Sprite.prototype.animDelay=1;Sprite.prototype.changeFrameDelay=1E3/24;Sprite.prototype.changeFrameTime=0;Sprite.prototype.onchangeframe=null;Sprite.prototype.cacheBitmap=!1; Sprite.create=function(a,c){if("string"==typeof a){c=c||window.library;if(!c)throw Error("Could not create sprite from asset '%s'. Library not found.",a);a=c.getAsset(a)}return new Sprite(a.bitmap,a.width||1,a.height||1,a.frames||1,a.layers||1)};Sprite.prototype.play=function(){this.animated=!0};Sprite.prototype.stop=function(){this.animated=!1};Sprite.prototype.gotoAndStop=function(a){this.currentFrame=a;this.stop()};Sprite.prototype.gotoAndPlay=function(a){this.currentFrame=a;this.play()}; Sprite.prototype.nextFrame=function(a){this.dispatchEvent("enterframe",{target:this,delta:a});var c=1;if(Sprite.CHANGE_FRAME_TYPE==Sprite.CHANGE_FRAME_BY_TIME)if(this.changeFrameTime+=a,this.changeFrameTime>=this.changeFrameDelay*this.animDelay)c=Math.floor(this.changeFrameTime/(this.changeFrameDelay*this.animDelay)),this.changeFrameTime-=Math.abs(c)*this.changeFrameDelay*this.animDelay;else return;else this.animStep++;if(this.animStep>=this.animDelay||Sprite.CHANGE_FRAME_TYPE==Sprite.CHANGE_FRAME_BY_TIME){for(var d= 0;d=this.totalFrames&&(this.currentFrame=0),0>this.animDirection&&0>this.currentFrame&&(this.currentFrame=this.totalFrames-1),this.dispatchEvent("changeframe",{target:this,delta:a});this.animStep=0}};Sprite.prototype.setMask=function(a){this.mask=a;this.mask.isMask=!0;this.mask.stage=this.stage;this.mask.maskParent=this}; Sprite.prototype.renderBack=function(a,c,d,e,f,g){c&&(a.ctx.save(),a.ctx.translate(-(f/2),-(g/2)),a.ctx.fillStyle=c,a.ctx.strokeStyle=c,a.ctx.fillRect(0,0,f,g),a.ctx.restore())}; Sprite.prototype.renderBitmap=function(a,c,d,e,f){var g={x:0,y:0,width:e,height:f};if(this.bitmap){var h=this.bitmap.width,l=this.bitmap.height,k=this.currentLayer*e+this.offset.left*Utils.globalScale,m=this.currentFrame*f+this.offset.top*Utils.globalScale;if(kh&&(n=h-k);m+p>l&&(p=l-m);Sprite.FLOOR_VALUES_ON_RENDER&&(k=~~k,m=~~m,n=~~n,p=~~p,c=~~c,d=~~d,e=~~e,f=~~f);0=this.timeout)if("string"==typeof this.onend?eval(this.onend):this.dispatchEvent("end",{target:this}),this.repeat)this.rewind();else return!0;this.dispatchEvent("tick",{target:this,delta:a});return!1};StageTimer.prototype.rewind=function(){this.timeout=this.initialTimeout}; StageTimer.prototype.resume=function(){this.paused=!1};StageTimer.prototype.pause=function(){this.paused=!0};StageTimer.TIMEOUT_BY_FRAME=0;StageTimer.TIMEOUT_BY_TIME=1;StageTimer.TIMEOUT_TYPE=StageTimer.TIMEOUT_BY_FRAME; function Stage(a,c,d){Utils.callSuperConstructor(Stage,this);this.canvas=null;a&&(this.canvas="string"==typeof a?document.getElementById(a):a,this.canvas.ctx=this.canvas.getContext("2d"));this.backgroundCanvas=null;this.needToRebuildBack=!1;this.screenWidth=c;this.screenHeight=d;this.viewport={x:0,y:0};this.buffer=null;try{this.buffer=document.createElement("canvas"),this.buffer.width=c*Utils.globalScale,this.buffer.height=d*Utils.globalScale,this.buffer.ctx=this.buffer.getContext("2d")}catch(e){this.buffer= this.canvas}this.delay=40;this.started=!1;this.lastFPS=this.fps=0;this.ceilSizes=this.pixelMouseMoveEvent=this.pixelMouseDownEvent=this.pixelMouseUpEvent=this.pixelClickEvent=this.showFPS=!1;this.tmFPS=this.tmMain=null;this.allowStaticDebugDrawing=this.allowDebugDrawing=this.clearLock=!1;this.drawBackAlways=Utils.mobileCheckBrokenAndroid();this.tweens=[];this.timers=[];this.eventsListeners=[];this.lastTick=0;this.onmousemove=this.oncontextmenu=this.onclick=this.onmouseup=this.onmousedown=this.onposttick= this.prerender=this.onpretick=this.inputController=null;this.canvas&&this.addInputListeners(this.canvas);this.tick=Utils.proxy(this.tick,this);this.clearFPS=Utils.proxy(this.clearFPS,this);this.stage=this;this.drawScene=this.render}Utils.extend(Stage,DisplayObjectContainer);Stage.prototype.refreshBackground=function(){this.needToRebuildBack=!0};Stage.prototype.setBackgroundCanvas=function(a){a&&(this.backgroundCanvas="string"==typeof a?document.getElementById(a):a,this.backgroundCanvas.ctx=this.backgroundCanvas.getContext("2d"))}; Stage.prototype.destroy=function(){clearTimeout(this.tmMain);clearTimeout(this.tmFPS);this.stop();this.clear();this.clearScreen(this.canvas);this.backgroundCanvas&&this.clearScreen(this.backgroundCanvas);this.removeInputListeners(this.stage)};Stage.prototype.clearScreen=function(a){this.clearLock||a.ctx.clearRect(0,0,Math.floor(a.width),Math.floor(a.height))};Stage.prototype.addChild=function(a){a.stage=this;return Utils.callSuperMethod(Stage,this,"addChild",a)}; Stage.prototype.setZIndex=function(a,c){this.setChildZIndex(a,c)};Stage.prototype.removeChild=function(a){a&&0<=this.objects.indexOf(a)&&(this.clearObjectTweens(a),a.stage=null,Utils.callSuperMethod(Stage,this,"removeChild",a))};Stage.prototype.finalizeMouseCoords=function(a,c){if(!a)return c;var d=this.prepareMouseCoord(c.x),e=this.prepareMouseCoord(c.y);a.getIgnoreViewport()||(d+=this.viewport.x,e+=this.viewport.y);var f=a.getAbsolutePosition(),d=d-f.x,e=e-f.y;return{x:d,y:e}}; Stage.prototype.prepareMouseCoord=function(a){return a/Utils.globalScale/Utils.globalPixelScale};Stage.prototype.processMouseEvent=function(a,c,d){a=Utils.getMouseCoord(a,this.inputController);d=this.getObjectsStackByCoord(this.prepareMouseCoord(a.x),this.prepareMouseCoord(a.y),d,!1);for(var e,f=0;fa.length)){for(var g=0;ga&&(a=1);this.fps++}this.started?this.tmMain=setTimeout(this.tick,a):this.lastTick=0}; Stage.prototype.box2dSync=function(a){for(b=a.m_bodyList;b;b=b.m_next)b.sprite&&(b.sprite.rotation=b.GetRotation(),a=b.GetPosition(),b.sprite.x=a.x,b.sprite.y=a.y,b.sprite.dispatchEvent("box2dsync",{target:b.sprite}))};Stage.prototype.processTouchEvent=function(a,c){for(var d=0;df&&(f=g,e=h)):d.push(h));0==d.length?!a&&0<=e&&(c=e):c=d[0];return c};AudioMixer.isWebAudioSupport=function(){return Boolean(window.AudioContext)};window.AudioContext=window.AudioContext||window.webkitAudioContext;AudioMixer.buffer={};AudioMixer.waContext=null; function Animation(a,c,d){this.obj=a;this.sequence=c;this.currentAnimation=-1;this.currentTweens=[];this.ended=!1;this.endTimer=this.startTimer=null;this.playNext=Utils.proxy(this.playNext,this);this.play=Utils.proxy(this.play,this);this.onfinish=d}Animation.prototype.play=function(){this.playNext()}; Animation.prototype.playNext=function(){if(0<=this.currentAnimation){var a=this.sequence[this.currentAnimation];if(a.onfinish)a.onfinish({target:this});"undefined"!=typeof a.loop&&0<=a.loop&&(this.currentAnimation=a.loop-1)}this.currentAnimation++;if(this.currentAnimation>=this.sequence.length){if(this.ended=!0,"function"==typeof this.onfinish)this.onfinish({target:this})}else{var a=this.sequence[this.currentAnimation],c,d,e,f,g,h,l;e=a.tweens;Utils.isArray(e)||(e=[e]);c=a.duration||0;this.currentTweens= [];for(var k=null,m=0;md){for(a=0;af)this.sprites[g].visible= !1;else{var h=this.getCharWidth(this.text.substr(g,1));this.sprites[g].scaleX=this.sprites[g].scaleY=this.scale;this.sprites[g].gotoAndStop(f);f=e.clone();f.x*=this.scale;f.rotate(-this.rotation);this.sprites[g].x=f.x+(","==this.text.substr(g,1)?c-h/2:c);this.sprites[g].y=f.y+d;this.sprites[g].rotation=this.rotation;this.sprites[g].static=this.static;this.sprites[g].opacity=this.opacity;this.sprites[g].ignoreViewport=this.ignoreViewport;this.sprites[g].gx=this.sprites[g].x;this.sprites[g].gy=this.sprites[g].y; this.sprites[g].gscaleX=this.sprites[g].scaleX;this.sprites[g].gscaleY=this.sprites[g].scaleY;this.sprites[g].grotation=this.sprites[g].rotation;this.sprites[g].gopacity=this.sprites[g].opacity;e.x+=h+this.charSpacing}};SimpleText.prototype.refresh=function(){this.write(this.text)};SimpleText.prototype.addToGroup=function(a){for(var c=0;c=d)this.setPosition(a,c);else{if(a=this.addTween("x",a,d,e,f,g))a.addEventListener("change",this.refreshOnTween),a.addEventListener("finish",this.refreshOnTween),a.play();if(c=this.addTween("y",c,d,e,a?null:f,a?null:g))c.addEventListener("change",this.refreshOnTween),c.addEventListener("finish",this.refreshOnTween),c.play()}return this};SimpleText.prototype.moveBy=function(a,c,d,e,f,g){return this.moveTo(this.x+a,this.y+c,d,e,f,g)}; SimpleText.prototype.fadeTo=function(a,c,d,e,f){c=~~c;if(0>=c)this.opacity=a;else if(a=this.addTween("opacity",a,c,d,e,f))a.play(),a.addEventListener("change",this.refreshOnTween),a.addEventListener("finish",this.refreshOnTween);return this};SimpleText.prototype.fadeBy=function(a,c,d,e,f){a=Math.max(0,Math.min(1,this.opacity+a));return this.fadeTo(a,c,d,e,f)}; SimpleText.prototype.rotateTo=function(a,c,d,e,f){c=~~c;if(0>=c)this.rotation=a;else if(a=this.addTween("rotation",a,c,d,e,f))a.play(),a.addEventListener("change",this.refreshOnTween),a.addEventListener("finish",this.refreshOnTween);return this};SimpleText.prototype.rotateBy=function(a,c,d,e,f){return this.rotateTo(this.rotation+a,c,d,e,f)}; SimpleText.prototype.scaleTo=function(a,c,d,e,f){c=~~c;if(0>=c)this.scale=a;else if(a=this.addTween("scale",a,c,d,e,f))a.play(),a.addEventListener("change",this.refreshOnTween),a.addEventListener("finish",this.refreshOnTween);return this};SimpleText.spriteClass="Sprite";SimpleText.ALIGN_LEFT=0;SimpleText.ALIGN_RIGHT=1;SimpleText.ALIGN_CENTER=2; function TilesSprite(a,c,d,e,f,g){TilesSprite.superclass.constructor.call(this,a,c,d,f,g);this.framesCount=e;this.animated=1=a.framesCount&&(a.currentFrameX=0),0>a.animDirection&&0>a.currentFrameX&&(a.currentFrameX=a.framesCount-1))};TilesSprite.sync=function(a){a=a.target;a.currentLayer=Math.floor(a.currentFrameX/a.totalFrames);a.currentFrame=a.currentFrameX-a.currentLayer*a.totalFrames}; var TTLoader={endCallback:null,loadedData:null,landscapeMode:!1,skipPlayButton:!1,create:function(a,c,d,e){TTLoader.endCallback=a;TTLoader.landscapeMode=c;TTLoader.skipPlayButton=d;document.getElementById("progress_container").style.background="#fff";document.getElementById("progress_container").style.zIndex="1000";a=document.getElementById("progress");a.setAttribute("valign","top");a.style.verticalAlign="top";a.style.background="#fff";c=document.createElement("div");d=document.createElement("a"); d.setAttribute("id","tt_load_logo_c");var f=window.ExternalAPI?ExternalAPI.exec("getPreloaderURL"):"http://yx8.com/",g="_blank";if(e||!f)f="javascript:void(0)",g="";d.setAttribute("href",f);d.setAttribute("target",g);e=new Image;e.setAttribute("id","tt_load_logo");e.setAttribute("border","");e.src=TTLoader.logoSrc;e.style.cursor="pointer";d.appendChild(e);c.appendChild(d);a.appendChild(c);c=document.createElement("div");c.setAttribute("id","tt_load_progress_cont");c.setAttribute("align","left"); c.setAttribute("style","padding: 1px; border: 2px solid #e44d26; background: #fff");e=document.createElement("div");e.setAttribute("id","tt_load_progress");e.setAttribute("style","width: 0px; background: #e44d26;");e.innerHTML=" ";c.appendChild(e);a.appendChild(c);c=document.createElement("div");c.setAttribute("id","tt_load_play");e=new Image;e.setAttribute("id","tt_load_button");e.src=TTLoader.buttonDisabledSrc;e.style.visibility=TTLoader.skipPlayButton?"hidden":"visible";c.appendChild(e);a.appendChild(c); Utils.addEventListener("fitlayout",TTLoader.setSizes);TTLoader.setSizes()},setSizes:function(){var a=Utils.getWindowRect();document.getElementById("progress_container").style.width=a.width+"px";document.getElementById("progress_container").style.height=a.height+"px";a=Utils.globalScale*Utils.globalPixelScale;TTLoader.landscapeMode||(document.getElementById("progress").style.paddingTop=Math.floor(80*a)+"px");document.getElementById("tt_load_progress_cont").style.width=Math.floor(200*a)+"px";document.getElementById("tt_load_progress").style.height= Math.floor(12*a)+"px";document.getElementById("tt_load_progress").style.width=a*TTLoader.progressVal*2+"px";document.getElementById("tt_load_logo").style.marginTop=Math.floor(80*a)+"px";document.getElementById("tt_load_logo").setAttribute("width",Math.floor(300*a)+"px");document.getElementById("tt_load_logo").setAttribute("height",Math.floor(65*a)+"px");document.getElementById("tt_load_button").setAttribute("width",Math.floor(65*a)+"px");document.getElementById("tt_load_button").setAttribute("height", Math.floor(29*a)+"px");document.getElementById("tt_load_button").style.marginTop=Math.floor(30*a)+"px"},progressVal:0,showLoadProgress:function(a){0>a&&(a=0);100=gameData.lastUnlockedLevel||!gameData.lastUnlockedLevel)gameData.lastUnlockedLevel=currentLevel+2,saveGameData(gameData);ExternalAPI.exec("showAds")}} function lose(){gameState=STATE_LOSE;alien.addFailAnimation();playMusic("lose_theme",!1);var a=-1===currentLevel;a&&(ExternalAPI.exec("gameOver",1,gameScore.val),ExternalAPI.exec("nextLevel",1,gameScore.val),ExternalAPI.exec("submitScore",gameScore.val,LEADERBOARD_ID));stage.setTimeout(function(){ExternalAPI.exec("showAds");showUIButtons();var c=addSprite("lvl_failed",198,241,160,240);c.setPropScale(0);var d=a?45:75;addToContainer(c,"btn_replay",52,52,50,d,!1,1,restart);addToContainer(c,"bt_menu", 52,52,-45,d,!1,2,showMenu);a||addToContainer(c,"ultimate_mode",132,44,0,20,!1,1,startUltimateMode);moves&&0>=moves.val?addToContainer(c,"out_of_moves",166,50,0,-40):addToContainer(c,"no_moves",115,50,0,-40);Animation.play(c,[{tweens:[{prop:"scaleX",to:1},{prop:"scaleY",to:1}],duration:Math.floor(2*fps/3),ease:Easing.exponential.easeOut,onfinish:function(){a&&ExternalAPI.exec("showAds")}}])},fps);ExternalAPI.exec("showAds")} function evolution(){if(gameState!==STATE_EVOLUTION){var a=gameState;gameState=STATE_EVOLUTION;var c=addSprite("evolution",320,487,160,240);c.setPropScale(0);addToContainer(c,a===STATE_LEVEL_SELECT?"bt_menu":"btn_play",52,52,0,185).onclick=function(){c.destroy=!0;gameState=a;return!1};Animation.play(c,[{tweens:[{prop:"scaleX",to:1},{prop:"scaleY",to:1}],duration:Math.floor(2*fps/3),ease:Easing.exponential.easeOut}])}} function pause(){if(gameState===STATE_GAME){gameState=STATE_PAUSE;showUIButtons();var a=addSprite("game_paused",198,168,160,240);a.setPropScale(0);var c=addToContainer(a,"btn_play",52,52,-40,40);addToContainer(a,"bt_menu",52,52,40,40,!1,1,showMenu);Animation.play(a,[{tweens:[{prop:"scaleX",to:1},{prop:"scaleY",to:1}],duration:Math.floor(fps/3),ease:Easing.exponential.easeOut,onfinish:function(){c.onclick=function(){a.destroy=!0;gameState=STATE_GAME;showUIButtons()}}}])}} function swipeDown(a){isAnimated||gameState!==STATE_GAME||(a.target.down={x:a.x,y:a.y},tutorial&&1!==tutorial.hint.num&&0!==tutorial.hint.opacity&&changeHint())} function swipeUp(a){if(!isAnimated&&gameState===STATE_GAME){var c=a.target.down;if(c&&!(170Math.max(Math.abs(d),Math.abs(c)))){var e=new Moving,f="",f=Math.abs(d)>Math.abs(c)?0gameData.bestScore&&(gameData.bestScore=gameScore.val,saveGameData(gameData),tBest.write(gameData.bestScore));a.target.down=null}}}} function changeScore(a,c,d){if(0!==c&&(a.val+=c,a.text.write(a.val),d=d||a.text,a===gameScore)){var e=new SimpleText(bitmaps.num_plus,15,25);e.align=e.ALIGN_CENTER;e.y=d.y-3;e.x=d.x;e.charMap="1234567890+".split("");var f="+"+c;e.write(f);Animation.play(e,[{tweens:[{prop:"y",to:d.y-60,onchange:function(){e.write(f)}},{prop:"opacity",to:0}],duration:Math.floor(2*fps/3),onfinish:function(){e.write("")}}])}}function restart(){startLevel(currentLevel)} function startUltimateMode(){ExternalAPI.exec("hideBanner");startLevel(-1);funtomic||setTutorial()}var uiContainer,moreGamesBtn; function startLevel(a){var c,d;ExternalAPI.exec("setRestartGame",restart);maxUnlockValue=0;isAnimated=!1;createStage();setCSSBack(bitmaps.background1);playMusic("game_music");addSprite("playfield",334,357,160,250,!0);uiContainer=addSprite(null,320,70,160,445);uiContainer.scaleY=0;c=!1;!0===ExternalAPI.exec("isPlainPortalEnvironment")&&isAndroid&&(c=!0,addToContainer(uiContainer,"btn_google_play_min",65,23,125,0,!1,2).onmousedown=function(){ExternalAPI.exec("sendGAEvent",categoryGP,actionGP,labelGP.gameScreen); ExternalAPI.exec("openPlayMarket",idGP,labelGP.gameScreen,categoryGP);return!1});"Spilgames"===ExternalAPI.type&&(c=!0,ExternalAPI.exec("addLogo",123,0,!0,uiContainer).setPropScale(.4));moreGamesBtn=addSprite("more_games",138,50,160,445);moreGamesBtn.onclick=showMoreGames;moreGamesBtn.scaleY=0;ExternalAPI.exec("getMoreGamesButtonDisable")&&(moreGamesBtn.visible=!1);var e=addToContainer(uiContainer,"btn_menu",60,60,-125,0,!1,2);attachMouseEvents.call(e);e.onmousedown=function(){gameState===STATE_GAME&& showMenu()};e=addToContainer(uiContainer,"btn_pause",60,60,c?-65:-60,0,!1,2);attachMouseEvents.call(e);e.onmousedown=pause;e=addToContainer(uiContainer,"btn_help",60,60,c?55:125,0,!1,2);attachMouseEvents.call(e);e.onmousedown=evolution;c=addToContainer(uiContainer,"btn_sound",60,60,c?-5:5,0,!1,2);c.onmousedown=function(a){gameState===STATE_GAME&&toggleSound(a)};isMusicOn?c.gotoAndStop(1):c.gotoAndStop(0);ExternalAPI.exec("setOnSound",toggleSound,c);ExternalAPI.exec("setOffSound",toggleSound,c);addKeyboardControl(); addSprite("score1",104,62,266,35,!0);addSprite("small_cell",15,15,70,77,!0);c=addSprite(null,320,480,160,240,!0);c.onmousedown=swipeDown;c.onmousemove=swipeUp;gameState=STATE_GAME;currentLevel=a;-1!==currentLevel?(addSprite("moves1",104,62,168,35,!0),a=levels[currentLevel].start,d=levels[currentLevel].finish,c=d[d.length-1].moves,e=new SimpleText(bitmaps.num_ingame,10,12),e.align=e.ALIGN_CENTER,e.x=168,e.y=40,e.write(c),moves={val:c,text:e}):(addSprite("best_score",94,53,168,35,!0),a=[{val:2,amount:2}], gameData=loadGameData(),tBest=new SimpleText(bitmaps.num_ingame,10,12),tBest.align=tBest.ALIGN_CENTER,tBest.x=168,tBest.y=40,tBest.write(gameData.bestScore),showUIButtons());c=new SimpleText(bitmaps.num_ingame,10,12);c.align=c.ALIGN_CENTER;c.y=40;c.x=266;c.write(0);gameScore={val:0,text:c};stage.start();alien=new Alien(65,50);fillGameField(a);if(d)for(showTarget(d),showTargetPopup(d),checkVictoryArr=[],a=0;ac.x&&c.gotoAndPlay(24))}}], duration:3.5*a}]);stage.setTimeout(showClouds,a)} function showTarget(a){checkVictoryTextArr=[];var c={};switch(a.length-1){case 1:c.x1=60;c.y1=70;break;case 2:c.x1=52;c.y1=70;c.x2=75;c.y2=70;break;case 3:c.x1=39,c.y1=70,c.x2=62,c.y2=73,c.x3=85,c.y3=70}for(var d=0;dd;d++){for(var e=[],f=0;4>f;f++)e.push(0);gameField.push(e)}var g;a.forEach(function(a){a.iceBlocks&&(g=a.iceBlocks)});if(g)for(f=0;f=moves.val)lose();else{for(var c=!0,d=0;da&&80c)return arguments.callee()}else if(75a&&200c)return arguments.callee();return{x:a,y:c}}stage.setInterval(function(){for(var c= 1;c--;)a()},fps/2)} var Alien=function(a,c){var d=this,e,f;this.init=function(){d.addDefaultSprite();d.setRandomTimer()};this.addDefaultSprite=function(){d.removeCurrentSprite();var g=new Sprite(bitmaps.mission,125,110);g.setPosition(a-.5,c-.5);stage.addChild(g);f?g.setZIndex(f):f=g.zIndex;e=g};this.removeCurrentSprite=function(){e&&(e.destroy=!0,stage.refreshBackground())};this.addFailAnimation=function(){d.removeCurrentSprite();var g=new TilesSprite(bitmaps.alien_fail,126,110,46,8,6);g.setPosition(a,c);g.setZIndex(f); g.animDelay=2;g.onenterframe=function(a){a=a.target;a.animated&&a.currentFrameX==a.framesCount-2&&a.stop()};stage.addChild(g);e=g};this.addElemAddedAnimation=function(){d.removeCurrentSprite();var g=new TilesSprite(bitmaps.alien_new_element,126,110,18,9,2);g.setPosition(a,c);g.setZIndex(f);g.onenterframe=function(a){a=a.target;a.animated&&a.currentFrameX==a.framesCount-2&&d.addDefaultSprite()};stage.addChild(g);e=g};this.addVictoryAnimation=function(){d.removeCurrentSprite();var g=new TilesSprite(bitmaps.alien_victory, 126,110,21,7,3);g.setPosition(a,c);g.setZIndex(f);g.onenterframe=function(a){a=a.target;a.animated&&a.currentFrameX==a.framesCount-2&&a.stop()};stage.addChild(g);e=g};this.setRandomTimer=function(){stage.setInterval(function(){gameState==STATE_GAME&&d.addRandomAnimation()},15*fps)};this.addRandomAnimation=function(a){d.removeCurrentSprite();a=d.getRandomSprite(a||Math.ceil(5*Math.random()));a.animDelay=2;a.setZIndex(f);a.onenterframe=a instanceof TilesSprite?function(a){a=a.target;a.currentFrameX== a.framesCount-2&&d.addDefaultSprite()}:function(a){a=a.target;a.currentFrame==a.totalFrames-2&&d.addDefaultSprite()};stage.addChild(a);e=a};this.getRandomSprite=function(d){var e=bitmaps["alien_random"+d];switch(d){case 1:return d=new Sprite(e,126,110,5),d.setPosition(a,c-.5),d;case 2:return d=new TilesSprite(e,126,110,10,5,2),d.setPosition(a,c-.5),d;case 3:return d=new TilesSprite(e,126,110,32,8,4),d.setPosition(a,c),d;case 4:return d=new TilesSprite(e,126,110,34,9,4),d.setPosition(a,c-.5),d;case 5:return d= new Sprite(e,126,110,6),d.setPosition(a,c-.5),d}};d.init()};function processReceiveValue(a){a>maxUnlockValue&&(maxUnlockValue=a,alien&&alien.addElemAddedAnimation(),playSound("new_sound"))}function playMusic(a,c){isMusicOn&&mixer.play(a,!1!==c,!1,0)}function playSound(a){isSoundOn&&AudioMixer.isWebAudioSupport()&&mixer.play(a,!1,!0)} function addLogoAnimation(a){function c(){var a=h[f];a&&a();g.currentFrameX=0;g.bitmap=bitmaps["logo_"+(f+1)];++f>=h.length&&(f=0)}var d=a.x,e=a.y,f=0;a.destroy=!0;stage.refreshBackground();var g=new TilesSprite(null,318,138,1,1,1);g.animDelay=6;g.setPosition(d,e);g.onchangeframe=function(a){a=a.target;a.currentFrameX==a.framesCount-1&&c()};stage.addChild(g);var h=[function(){g.totalFrames=4;g.totalLayers=2;g.framesCount=8},function(){g.totalFrames=5;g.totalLayers=1;g.framesCount=5},function(){g.totalFrames= 5;g.totalLayers=2;g.framesCount=9}];c();g.play()}function addKeyboardControl(){document.addEventListener("keydown",function(a){switch(a.keyCode){case 37:keyboardMove("left");break;case 39:keyboardMove("right");break;case 38:keyboardMove("up");break;case 40:keyboardMove("down")}})} function keyboardMove(a){if(!isAnimated&&gameState===STATE_GAME){if(tutorial){if(!tutorial.hand.willDestroy)if("left"===a||"right"===a)tutorial.hand.fadeTo(0,fps/2,!1,function(){tutorial.hand.destroy=!0}),tutorial.hand.willDestroy=!0;else return;0!==tutorial.hint.opacity&&changeHint()}if(fTutorial)if(a===fTutorial.states[fTutorial.state].direction)fTutorial.changeState();else return;var c=new Moving;switch(a){case "right":c.right();break;case "left":c.left();break;case "up":c.up();break;case "down":c.down()}c.addNew(); playSound("move_sound");c.evolutionSprite&&processReceiveValue(c.evolutionSprite.val);changeScore(gameScore,c.sum,c.evolutionSprite);-1!==currentLevel&&c.isMoving?changeScore(moves,-1):gameScore.val>gameData.bestScore&&-1===currentLevel&&(gameData.bestScore=gameScore.val,saveGameData(gameData),tBest.write(gameData.bestScore))}} function showBrandingLogo(a,c,d){ExternalAPI.exec("getBrandingLogo",function(e){if(e=new Sprite(e,e.width/Utils.globalScale,e.height/Utils.globalScale))e.x=c,e.y=d,e.onclick=function(){ExternalAPI.exec("handleBrandingClick")};a.addChild(e)})}function setTutorial(){tutorial={};tutorial.hand=setTutorialHand(145,265);tutorial.hint=addSprite("hint1",163,50,160,358);tutorial.hint.num=1} function changeHint(){var a=tutorial.hint.num;a++;tutorial.hint.destroyByOpacity();4>a?(2===a&&(tutorial.hint=addSprite("hint2",230,53,160,358)),3===a&&(tutorial.hint=addSprite("hint3",213,40,160,358)),tutorial.hint.num=a,tutorial.hint.opacity=0,tutorial.hint.fadeTo(1,fps/3)):tutorial=!1} function setTutorialHand(a,c,d,e,f){var g;g=tutorial&&!tutorial.hand||fTutorial&&!fTutorial.hand?addSprite("hand",44,69,a,c):tutorial?tutorial.hand:fTutorial.hand;e=e||"x";a="y"===e?c:a;f=f||fps;var h=[{tweens:[{prop:e,to:a+(d||-72)}],duration:f,ease:Easing.exponential.easeOut},{tweens:[{prop:e,to:a}],duration:f,ease:Easing.exponential.easeOut,onfinish:function(){Animation.play(g,h)}}];Animation.play(g,h);return g} function setFuntomicTutorial(){fTutorial={};fTutorial.states=[{hand:{x:145,y:265},direction:"left"},{newElememt:{x:1,y:2,val:2},hand:{x:145,y:337,distance:72,direction:"y"},direction:"down"},{newElememt:{x:1,y:1,val:2},hand:{x:145,y:265,distance:144,direction:"y",dur:1.5*fps},direction:"down"}];fTutorial.state=0;fTutorial.hand=setTutorialHand(145,265);fTutorial.changeState=function(){fTutorial.hand.removeTweens();if(fTutorial.state===fTutorial.states.length-1){var a=fTutorial.hand;a.setZIndex(stage.findMaxZIndex().zIndex+ 1);a.moveTo(80,115,fps,!1,function(){fTutorial=!1;stage.setTimeout(function(){a.destroyByOpacity();blinkTarget()},fps/2)})}else{fTutorial.state++;var c=fTutorial.states[fTutorial.state].hand;fTutorial.hand.moveTo(c.x,c.y,fps/2,!1,function(){setTutorialHand(c.x,c.y,c.distance,c.direction,c.dur)})}}};