canvasengine 1.3.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +51 -17
- package/src/components/Canvas.ts +134 -0
- package/src/components/Container.ts +46 -0
- package/src/components/DisplayObject.ts +458 -0
- package/src/components/DrawMap/index.ts +65 -0
- package/src/components/Graphic.ts +147 -0
- package/src/components/NineSliceSprite.ts +46 -0
- package/src/components/ParticleEmitter.ts +39 -0
- package/src/components/Scene.ts +6 -0
- package/src/components/Sprite.ts +493 -0
- package/src/components/Text.ts +145 -0
- package/src/components/Tilemap/Tile.ts +79 -0
- package/src/components/Tilemap/TileGroup.ts +207 -0
- package/src/components/Tilemap/TileLayer.ts +163 -0
- package/src/components/Tilemap/TileSet.ts +41 -0
- package/src/components/Tilemap/index.ts +80 -0
- package/src/components/TilingSprite.ts +39 -0
- package/src/components/Viewport.ts +159 -0
- package/src/components/index.ts +13 -0
- package/src/components/types/DisplayObject.ts +69 -0
- package/src/components/types/MouseEvent.ts +3 -0
- package/src/components/types/Spritesheet.ts +389 -0
- package/src/components/types/index.ts +4 -0
- package/src/directives/Drag.ts +84 -0
- package/src/directives/KeyboardControls.ts +922 -0
- package/src/directives/Scheduler.ts +101 -0
- package/src/directives/Sound.ts +91 -0
- package/src/directives/Transition.ts +45 -0
- package/src/directives/ViewportCull.ts +40 -0
- package/src/directives/ViewportFollow.ts +26 -0
- package/src/directives/index.ts +7 -0
- package/src/engine/animation.ts +113 -0
- package/src/engine/bootstrap.ts +19 -0
- package/src/engine/directive.ts +23 -0
- package/src/engine/reactive.ts +379 -0
- package/src/engine/signal.ts +138 -0
- package/src/engine/trigger.ts +40 -0
- package/src/engine/utils.ts +135 -0
- package/src/hooks/addContext.ts +6 -0
- package/src/hooks/useProps.ts +155 -0
- package/src/hooks/useRef.ts +21 -0
- package/src/index.ts +13 -0
- package/src/utils/Ease.ts +33 -0
- package/src/utils/RadialGradient.ts +86 -0
- package/.gitattributes +0 -22
- package/.npmignore +0 -163
- package/canvasengine-1.3.0.all.min.js +0 -21
- package/canvasengine.js +0 -5802
- package/core/DB.js +0 -24
- package/core/ModelServer.js +0 -348
- package/core/Users.js +0 -190
- package/core/engine-common.js +0 -952
- package/doc/cocoonjs.md +0 -36
- package/doc/doc-lang.yml +0 -43
- package/doc/doc-router.yml +0 -14
- package/doc/doc-tuto.yml +0 -9
- package/doc/doc.yml +0 -39
- package/doc/element.md +0 -37
- package/doc/entity.md +0 -90
- package/doc/extend.md +0 -47
- package/doc/get_started.md +0 -19
- package/doc/images/entity.png +0 -0
- package/doc/multitouch.md +0 -58
- package/doc/nodejs.md +0 -142
- package/doc/scene.md +0 -44
- package/doc/text.md +0 -156
- package/examples/server/client.html +0 -31
- package/examples/server/server.js +0 -16
- package/examples/tiled_server/client.html +0 -52
- package/examples/tiled_server/images/tiles_spritesheet.png +0 -0
- package/examples/tiled_server/server/map.json +0 -50
- package/examples/tiled_server/server/map.tmx +0 -16
- package/examples/tiled_server/server/server.js +0 -16
- package/extends/Animation.js +0 -910
- package/extends/Effect.js +0 -252
- package/extends/Gleed2d.js +0 -252
- package/extends/Hit.js +0 -1509
- package/extends/Input.js +0 -699
- package/extends/Marshal.js +0 -716
- package/extends/Scrolling.js +0 -388
- package/extends/Soundmanager2.js +0 -5466
- package/extends/Spritesheet.js +0 -196
- package/extends/Text.js +0 -366
- package/extends/Tiled.js +0 -403
- package/extends/Window.js +0 -575
- package/extends/gamepad.js +0 -397
- package/extends/socket.io.min.js +0 -2
- package/extends/swf/soundmanager2.swf +0 -0
- package/extends/swf/soundmanager2_debug.swf +0 -0
- package/extends/swf/soundmanager2_flash9.swf +0 -0
- package/extends/swf/soundmanager2_flash9_debug.swf +0 -0
- package/extends/swf/soundmanager2_flash_xdomain.zip +0 -0
- package/extends/workers/transition.js +0 -43
- package/index.js +0 -46
- package/license.txt +0 -19
- package/readme.md +0 -483
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Canvas Engine JavaScript Library 1.3.0
|
|
3
|
-
* http:/canvasengine.net
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2012, WebCreative5, Samuel Ronce
|
|
6
|
-
* Licensed under the MIT.
|
|
7
|
-
*
|
|
8
|
-
* Date: September 14, 2012
|
|
9
|
-
* Update : Fri Sep 27 10:10:57 2013
|
|
10
|
-
*/
|
|
11
|
-
var fs;if(typeof(require)!=="undefined"){fs=require("fs")}function Kernel(b,a){this.class_method=b;this.class_name=a}Kernel._extend=function(a,b,g){var f;if(!(b instanceof Array)){b=[b]}for(var e=0;e<b.length;e++){g=g===undefined?true:g;f=b[e];if(typeof f=="string"){if(Class.__class_config[f]){f=Class.__class_config[f].methods}else{return a}}if(g){f=CanvasEngine.clone(f)}for(var d in f){a[d]=f[d]}}return a};Kernel.prototype={New:function(){return this["new"].apply(this,arguments)},"new":function(){this._class=new Class();Class.__class[this.class_name]=this._class;this._construct();return this._class},_construct:function(){this._class.extend(this.class_method)},_attr_accessor:function(d,a,f){var b=this;for(var e=0;e<d.length;e++){this.class_method["_"+d[e]]=null;this.class_method[d[e]]={};if(a){this.class_method[d[e]].set=function(g){b.class_method["_"+d[e]]=g}}if(f){this.class_method[d[e]].get=function(){return b.class_method["_"+d[e]]}}}return this},attr_accessor:function(a){return this._attr_accessor(a,true,true)},attr_reader:function(a){return this._attr_accessor(a,true,false)},attr_writer:function(a){return this._attr_accessor(a,false,true)},extend:function(a,b){Kernel._extend(this.class_method,a,b);return this},addIn:function(a){if(!Class.__class[a]){return this}Class.__class[a][this.name]=this;return this}};function Class(){this.name=null}Class.__class={};Class.__class_config={};Class.get=function(a){return Class.__class[a]};Class.create=function(e,d,h){var g,b,a;Class.__class_config[e]={};Class.__class[e]={};if(h){g=window[e];tmp_class=new Class();for(var f in tmp_class){g[f]=tmp_class[f]}for(var f in d){g[f]=d[f]}b=g}else{Class.__class_config[e].methods=d;var i=Class.__class_config[e].kernel=new Kernel(Class.__class_config[e].methods,e)}return i};Class.New=function(){return Class["new"].apply(this,arguments)};Class["new"]=function(d,e,a){var b;if(typeof e=="boolean"){a=e;e=[]}if(a==undefined){a=true}e=e||[];if(!Class.__class_config[d]){throw d+' class does not exist. Use method "create" for build the structure of this class'}b=Class.__class_config[d].kernel["new"]();if(a&&b.initialize){b.initialize.apply(b,e)}b.__name__=d;return b};Class.prototype={extend:function(a,b){return Kernel._extend(this,a,b)}};var CanvasEngine={};CanvasEngine.uniqid=function(){return Math.random()};CanvasEngine.arraySplice=function(b,d){var a;for(a=0;a<d.length;++a){if(b==d[a]){d.splice(a,1);return}}};CanvasEngine.ajax=function(a){a=CanvasEngine.extend({url:"./",type:"GET",statusCode:{}},a);a.data=a.data?JSON.stringify(a.data):null;if(fs){fs.readFile("./"+a.url,"ascii",function(i,e){if(i){throw i}e=e.toString("ascii");if(a.dataType=="json"){e=CanvasEngine.parseJSON(e)}a.success(e)});return}var h;try{h=new ActiveXObject("Msxml2.XMLHTTP")}catch(f){try{h=new ActiveXObject("Microsoft.XMLHTTP")}catch(d){try{h=new XMLHttpRequest()}catch(b){h=false}}}function g(){var e;if(a.success){e=h.responseText;if(a.dataType=="json"){e=CanvasEngine.parseJSON(e)}else{if(a.dataType=="xml"){e=h.responseXML}}a.success(e)}}h.onreadystatechange=function(){if(h.readyState==4){if(a.statusCode&&a.statusCode[h.status]){a.statusCode[h.status]()}if(h.status==200){g()}else{if(a.error){a.error(h)}}}};h.open(a.type,a.url,true);if(a.mimeType){h.overrideMimeType(a.mimeType)}h.send(a.data)};CanvasEngine.getJSON=function(a,b,d){if(typeof b=="function"){d=b;b=null}CanvasEngine.ajax({url:a,dataType:"json",data:b,success:d})};CanvasEngine.parseJSON=function(a){return JSON.parse(a)};CanvasEngine.each=function(e,d){var b,a;if(e instanceof Array){a=e.length}else{a=e;e=[]}for(b=0;b<a;++b){d.call(e,b,e[b])}};CanvasEngine.inArray=function(b,d){var a;for(a=0;a<d.length;++a){if(b==d[a]){return a}}return -1};CanvasEngine.clone=function(a){var d;if(typeof(a)!="object"||a==null){return a}var b=a.constructor();if(b===undefined){return a}for(d in a){b[d]=CanvasEngine.clone(a[d])}return b};CanvasEngine.hexaToRGB=function(h){var f,e,a;function d(b){return(b.charAt(0)=="#")?b.substring(1,7):b}f=parseInt((d(h)).substring(0,2),16);e=parseInt((d(h)).substring(2,4),16);a=parseInt((d(h)).substring(4,6),16);return[f,e,a]};CanvasEngine.rgbToHex=function(e,d,a){return((1<<24)+(e<<16)+(d<<8)+a).toString(16).slice(1)};CanvasEngine._getRandomColorKey=function(){var e=Math.round(Math.random()*255),d=Math.round(Math.random()*255),a=Math.round(Math.random()*255);return CanvasEngine.rgbToHex(e,d,a)};CanvasEngine.random=function(b,a){return Math.floor((Math.random()*a)+b)};CanvasEngine.mobileUserAgent=function(){var a=navigator.userAgent;if(a.match(/(iPhone)/)){return"iphone"}else{if(a.match(/(iPod)/)){return"ipod"}else{if(a.match(/(iPad)/)){return"ipad"}else{if(a.match(/(BlackBerry)/)){return"blackberry"}else{if(a.match(/(Android)/)){return"android"}else{if(a.match(/(Windows Phone)/)){return"windows phone"}else{return false}}}}}}};CanvasEngine._benchmark={};CanvasEngine._interval_benchmark=60;CanvasEngine._freq_benchmark={};CanvasEngine.microtime=function(){var a=new Date().getTime()/1000;var b=parseInt(a,10);return a*1000};CanvasEngine.benchmark=function(b){var a=this.microtime();if(this._benchmark[b]){console.log("Performance "+b+" : "+(a-this._benchmark[b])+"ms")}this._benchmark[b]=a};CanvasEngine.objectSize=function(d){var b=0,a;for(a in d){if(d.hasOwnProperty(a)){b++}}return b};CanvasEngine.extend=function(b,a,d){if(!b){b={}}if(!a){a={}}return Kernel._extend(b,a,d)};if(typeof exports=="undefined"){var _ua=navigator.userAgent.toLowerCase(),_version=/(chrome|firefox|msie|version)(\/| )([0-9.]+)/.exec(_ua);CanvasEngine.browser={mozilla:/mozilla/.test(_ua)&&!/webkit/.test(_ua),webkit:/webkit/.test(_ua),opera:/opera/.test(_ua),msie:/msie/.test(_ua),version:_version?_version[3]:null,which:function(){var a;CanvasEngine.each(["mozilla","webkit","opera","msie"],function(d,b){if(CanvasEngine.browser[b]){a=b}});return{ua:a,version:CanvasEngine.browser.version}}}}CanvasEngine.moveArray=function(f,e,d){var b,a;e=parseInt(e,10);d=parseInt(d,10);if(e!==d&&0<=e&&e<=f.length&&0<=d&&d<=f.length){a=f[e];if(e<d){for(b=e;b<d;b++){f[b]=f[b+1]}}else{for(b=e;b>d;b--){f[b]=f[b-1]}}f[d]=a}return f};CanvasEngine.toTimer=function(e){var a=""+Math.floor(e/60/60),b=""+Math.floor(e/60%60),d=""+Math.floor(e%60);if(a.length==1){a="0"+a}if(b.length==1){b="0"+b}if(d.length==1){d="0"+d}return{hour:a,min:b,sec:d}};CanvasEngine.algo={pascalTriangle:function(a){a=a||10;var f=[[1,1],[1,2,1]],b=a-f.length;for(var e=f.length;e<=b;e++){f[e]=[1];for(var d=1;d<=e;d++){f[e][d]=f[e-1][d]+f[e-1][d-1]}f[e][e+1]=1}return f},};CanvasEngine.toMatrix=function(h,g,a){var d=[],b=0;for(var e=0;e<a;e++){for(var f=0;f<g;f++){if(!d[f]){d[f]=[]}d[f][e]=h[b];b++}}return d};CanvasEngine.rotateMatrix=function(g,e){var a=[],f=[];e=e||"90";if(e=="90"||e=="-90"){for(var b=0;b<g[0].length;b++){a[b]=[];for(var d=0;d<g.length;d++){a[b][d]=g[d][b]}}}if(e=="-90"){var b=0;for(var d=a.length-1;d>=0;d--){f[b]=a[d];b++}return f}if(e=="180"){for(var d=0;d<g.length;d++){a[d]=g[d].reverse()}}return a};var _CanvasEngine=CanvasEngine;if(typeof(exports)!=="undefined"){exports.Class=Class;exports.CanvasEngine=CanvasEngine}(function(){var b=0;var d=["ms","moz","webkit","o"];for(var a=0;a<d.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[d[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[d[a]+"CancelAnimationFrame"]||window[d[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(i,f){var e=new Date().getTime();var g=Math.max(0,16-(e-b));var h=window.setTimeout(function(){i(e+g)},g);b=e+g;return h}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(e){clearTimeout(e)}}}());if(typeof Element!="undefined"){var prop,vendors=["ms","moz","webkit","o","khtml"];for(var x=0;x<vendors.length&&!Element.prototype.requestFullScreen;++x){Element.prototype.requestFullScreen=Element.prototype[vendors[x]+"RequestFullScreen"];document.cancelFullScreen=document[vendors[x]+"CancelFullScreen"]}}Class.create("ModelClientClass",{create:function(b,d,a){if(!(d instanceof Array)){a=d;d=false}a.events=d;Class.create(b,a)},"new":function(b){var a=Class["new"](b).extend({_methods:{},emit:function(f,i,k){if(!i){i=[]}if(typeof i=="function"){k=i}if(k){this.on(f,k)}if(this[f]){if(!(i instanceof Array)){var h=[];for(var g in i){h.push(i[g])}i=h}var e=this[f].apply(this,i);this.call(f,e)}},on:function(e,f){if(!this._methods[e]){this._methods[e]={}}this._methods[e].callback=f},call:function(e,f){if(this._methods[e]){this._methods[e].callback(f)}}});if(this.events){for(var d in this.events){obj=a[events[d]];if(obj){obj.on(this.events[d],function(e){if(!e){e={}}obj.call(a,e)})}}}return a}});var Model=Class["new"]("ModelClientClass"),Global_CE;CanvasEngine.io=null;CanvasEngine.socketIO=function(){if(typeof(io)=="undefined"){throw"Please add socket.io - http://socket.io"}return io};CanvasEngine.User={authentication:function(d,a,b){CanvasEngine.socketIO();CanvasEngine.io.emit("_authentication",{username:d,password:a});CanvasEngine.io.on("_authentication",function(e){if(e.ret=="success"&&b.success){b.success()}else{if(e.ret=="failed"&&b.failed){b.failed(e.err)}}})},register:function(d,a,b){CanvasEngine.socketIO();CanvasEngine.io.emit("_register",{username:d,password:a,data:b.data});CanvasEngine.io.on("_register",function(e){if(e.ret=="success"&&b.success){b.success()}else{if(e.ret=="failed"&&b.failed){b.failed(e.err)}}})}};CanvasEngine.connectServer=function(b,a){CanvasEngine.socketIO();CanvasEngine.io=io.connect(b+":"+a)};CanvasEngine.defines=function(a,d){d=d||{};if(d.render===undefined){d.render=true}if(typeof a=="string"){a=[a]}var b;Class.create("CanvasEngineClass",{_noConflict:false,initialize:function(e){this.canvas=a;this.el_canvas=[]},ready:function(g){var e=this;b.Sound._manager=typeof(soundManager)!=="undefined";if(b.Sound._manager){soundManager.setup(_CanvasEngine.extend({url:d.swf_sound?d.swf_sound:"swf/",onready:f},d.soundmanager))}else{if(!g){f()}else{window.onload=f}}function f(){for(var h=0;h<e.canvas.length;h++){e.el_canvas.push(e.Canvas["new"](e.canvas[h]))}if(d.render){b.Scene._loop(e.el_canvas)}if(g){g()}}return this},plugins:function(){},mouseover:false,noConflict:function(){this._noConflict=true},Materials:{images:{},_buffer:{},_cache_canvas:{},sounds:{},videos:{},fonts:{},data:{},get:function(f,e){if(e){return this[e+"s"][f]}if(_m=this.images[f]||this.sounds[f]||this.videos[f]||this.data[f]){return _m}else{if(f instanceof Image||f instanceof HTMLCanvasElement||f instanceof HTMLVideoElement||f instanceof HTMLAudioElement){return f}}if(d.ignoreLoadError){return false}throw'Cannot to get the data "'+f+'" because it does not exist'},imageToCanvas:function(m,l){l=l||{};if(this._cache_canvas[m]&&l.cache){return this._cache_canvas[m]}var g=this.get(m),i,f;if(!g){return}var e=l.width||g.width,k=l.height||g.height,i=document.createElement("canvas");i.width=e;i.height=k;f=i.getContext("2d");f.drawImage(g,0,0,g.width,g.height,0,0,e,k);this._cache_canvas[m]={canvas:i,ctx:f};return this._cache_canvas[m]},createBuffer:function(e){var f="_opaque_"+e;if(!this._buffer[f]){this._buffer[f]=this.opaqueImage(e)}return this._buffer[f]},transparentColor:function(g,o,f){var e,q,s,r=this.imageToCanvas(g,{cache:f}),h=r.canvas,u=r.ctx;e=u.getImageData(0,0,h.width,h.height);q=e.data;s=_CanvasEngine.hexaToRGB(o);for(var p=0,k=q.length;p<k;p+=4){var l=q[p];var m=q[p+1];var t=q[p+2];if(l==s[0]&&m==s[1]&&t==s[2]){q[p+3]=0}}u.putImageData(e,0,0);return h},invertColor:function(n,f){var m,l,k=this.imageToCanvas(n),g=k.canvas,e=k.ctx;m=e.getImageData(0,0,g.width,g.height);l=m.data;for(var h=0;h<l.length;h+=4){l[h]=255-l[h];l[h+1]=255-l[h+1];l[h+2]=255-l[h+2]}e.putImageData(m,0,0);return g},cropImage:function(f,o,n,p,k){var e,i,m,l=this.imageToCanvas(f);if(!l){return}var g=l.canvas,q=l.ctx;e=q.getImageData(o,n,p,k);g.width=p;g.height=k;q.putImageData(e,0,0);return g},opaqueImage:function(k){var h=this.imageToCanvas(k),f=h.canvas,e=h.ctx;imageData=e.getImageData(0,0,f.width,f.height);data=imageData.data;for(var g=0;g<data.length;g+=4){if(data[g+3]>0){data[g+3]=255}}e.putImageData(imageData,0,0);return f},getExtension:function(e){return(/[.]/.exec(e))?/[^.]+$/.exec(e)[0]:undefined},getBasePath:function(g,e){var f=g.substring(0,g.lastIndexOf("/"));return f!=""&&e?f+"/":f},getFilename:function(g,e){var f=g.replace(/^.*[\\\/]/,"");if(!e){f=f.split(".")}else{return f}return f.slice(0,f.length-1).join(".")},Transition:{_data:{},set:function(n,l){var m,h,e=[];if(this._data[n]){return this._data[n]}if(!(n instanceof Array)){var k=b.Materials.imageToCanvas(n,{width:1024,height:768});if(typeof Uint8ClampedArray!="undefined"){e=new Uint8ClampedArray(k.canvas.width*k.canvas.height)}m=k.ctx.getImageData(0,0,k.canvas.width,k.canvas.height);h=m.data;var f=0;for(var g=0;g<h.length;g+=4){e[f]=h[g];f++}}else{e=l}this._data[n]=e;return e},get:function(e){return this._data[e]}},load:function(o,w,q,n){var h=0,e,u=this,t=[],v;if(!(w instanceof Array)){w=[w]}for(var g=0;g<w.length;g++){e=w[g];if(e.id){t.push(e)}else{for(var s in e){v={};v=_CanvasEngine.extend({},e[s]);if(typeof e[s]=="string"){v.path=e[s]}if(v.id){v._id=v.id}v.id=s;t.push(v)}}}switch(o){case"images":r();break;case"sounds":k();break;case"fonts":f();break;case"videos":m();break;case"data":l();break}function r(){var i;if(t[h]){i=new Image();i.onload=function(){var p;if(t[h].transparentcolor){p=u.transparentColor(i,t[h].transparentcolor)}if(t[h].invertcolor){p=u.invertColor(i)}else{p=i}u.images[t[h].id]=p;if(t[h].transition){u.Transition.set(t[h].id)}h++;if(q){q.call(u,p)}r()};i.onerror=function(p){if(d.ignoreLoadError){h++;if(q){q.call(u,p)}r()}};i.src=t[h].path}else{if(n){n.call(u)}}}function k(){var B;function C(){h++;if(q){q.call(u,this)}k()}if(t[h]){if(b.Sound._manager){if(u.sounds[t[h].id]){C()}else{u.sounds[t[h].id]=soundManager.createSound({id:t[h].id,url:t[h].path,autoLoad:true,autoPlay:false,onload:C,onfinish:function(){if(this._loop){this.play()}}})}}else{var A=new Audio(),p=t[h].path,y=u.getBasePath(p),i=u.getFilename(p),z=u.getExtension(p);var E={mp3:A.canPlayType("audio/mpeg"),ogg:A.canPlayType('audio/ogg; codecs="vorbis"'),m4a:A.canPlayType('audio/mp4; codecs="mp4a.40.2"')};if(!E[z]){for(var D in E){if(z==D){continue}if(E[D]){p=y+"/"+i+"."+D;break}}}A.setAttribute("src",p);A.addEventListener("canplaythrough",function(){u.sounds[t[h].id]=this;C()},false);A.addEventListener("ended",function(){if(!this._loop){return}this.currentTime=0;this.play()},false);A.addEventListener("error",function(F){if(d.ignoreLoadError){C()}},false);A.load();A.pause();document.body.appendChild(A);if(/^i/.test(_CanvasEngine.mobileUserAgent())){u.sounds[t[h].id]=A;C()}}}else{if(n){n.call(u)}}}function f(){var i=t[h];if(i){if(i.id=="google"||i.id=="ascender"||i.id=="typekit"||i.id=="monotype"||i.id=="fontdeck"){var A={};A[i.id]=i;if(i._id){A[i.id].id=i._id}if(typeof WebFontConfig=="undefined"){WebFontConfig={}}WebFontConfig=_CanvasEngine.extend(WebFontConfig,A)}else{var y=document.createElement("style");var z=u.getBasePath(i.path,true)+u.getFilename(i.path)+"."+(_CanvasEngine.browser.msie?"eot":"ttf");y.innerHTML="@font-face { font-family: '"+i.id+"'; src: url('"+z+"'); font-weight: normal; font-style: normal;}";document.getElementsByTagName("head")[0].appendChild(y)}h++;if(q){q.call(u,this)}f()}else{if(!document.getElementById("google-webfont")){var p=document.createElement("script");p.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";p.type="text/javascript";p.async="true";p.id="google-webfont";var y=document.getElementsByTagName("script")[0];y.parentNode.insertBefore(p,y)}if(n){n.call(u)}}}function m(){function z(){h++;if(q){q.call(u,this)}m()}if(t[h]){var y=document.createElement("video");if(t[h].webcam){navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;function i(A){window.stream=A;if(window.URL){y.src=window.URL.createObjectURL(A)}else{y.src=A}u.videos[t[h].id]=y;z()}function p(A){throw"navigator.getUserMedia error: "+A}navigator.getUserMedia(t[h].webcam,i,p)}else{y.src=t[h].path;y.addEventListener("loadeddata",function(){u.videos[t[h].id]=y;z()},false);y.onerror=function(A){if(d.ignoreLoadError){z()}else{throw"Video error #"+A.target.error.code+": See http://dev.w3.org/html5/spec-author-view/video.html#dom-mediaerror-media_err_aborted"}};y.load()}document.body.appendChild(y);y.setAttribute("style","display:none;")}else{if(n){n.call(u)}}}function l(){function i(){h++;if(q){q.call(u,this)}l()}if(t[h]){_CanvasEngine.ajax({url:t[h].path,dataType:"json",success:function(p){u.data[t[h].id]=p;i()},error:function(){if(d.ignoreLoadError){i()}}})}else{if(n){n.call(u)}}}}},Sound:{_fade:{},_manager:false,get:function(f){var e=b.Materials.get(f,"sound");return e},allStop:function(g){g=g||"";var e=b.Materials.sounds;for(var f in e){if(f!=g){this.stop(f)}}return this},stop:function(f){var e=this.get(f);if(d.soundmanager){e.stop()}else{e.currentTime=0;e.pause()}e._loop=false;return this},play:function(e){this.get(e).play();return this},playOnly:function(e){this.allStop(e);this.get(e).play();return this},playLoop:function(f){var e=this.get(f);e._loop=true;e.play();return this},fadeIn:function(g,e,f){this.fadeTo(g,e,1,f)},fadeOut:function(g,e,f){this.fadeTo(g,e,0,f)},fadeTo:function(k,g,i,h){var f=this.get(k),e=this._manager?f.volume/100:f.volume;this._fade[k]={sound:f,init:e,c_volume:e,f_time:g,to:i,callback:h}},_loop:function(){var g,f;for(var e in this._fade){g=this._fade[e];f=false;if(g){if(g.init<g.to){if(g.c_volume>=g.to){g.c_volume=g.to;f=true}else{g.c_volume+=(Math.abs(g.to-g.init)/g.f_time)}if(g.c_volume>0.999){g.c_volume=1}}else{if(g.c_volume<=g.to){g.c_volume=g.to;f=true}else{g.c_volume-=(Math.abs(g.to-g.init)/g.f_time)}if(g.c_volume<0.001){g.c_volume=0}}if(this._manager){g.sound.setVolume(g.c_volume*100)}else{g.sound.volume=g.c_volume}if(f){if(g.callback){g.callback.call(g.sound)}delete this._fade[e];break}}}}},Canvas:{"new":function(e){return Class["new"]("Canvas",[e])}},Element:{"new":function(h,f,g,e){return Class["new"]("Element",[h,f,g,e])}},Context:{"new":function(e){return Class["new"]("Context",[e])}},Scene:{_scenes:{},_cacheScene:{},_scenesEnabled:{},_scenesIndex:[],_scenesNbCall:{},_current:null,New:function(){return this["new"].apply(this,arguments)},"new":function(f){var e;if(typeof f=="string"){if(!this._cacheScene[f]){throw"Please initialize '"+f+"' scene with an object before"}f=this._cacheScene[f]}else{this._cacheScene[f.name]=f}e=Class["new"]("Scene",[f]).extend(f,false);this._scenesNbCall[f.name]=0;this._scenes[f.name]=e;return e},call:function(g,h){if(this._scenesNbCall[g]>0){this.New(g)}var e=this._scenes[g],f=[g];h=h||{};if(e){this._scenesEnabled[g]=e;if(this._scenesIndex.indexOf(g)==-1){if(h.transition){this._scenesIndex=f.concat(this._scenesIndex)}else{this._scenesIndex.push(g)}}if(h.exitScenes){h.exitScenes.allExcept=h.exitScenes.allExcept||[];h.exitScenes.allExcept=f.concat(h.exitScenes.allExcept);e._load.call(e,h.exitScenes,h.params)}else{if(!h.overlay&&!h.transition){this.exitAll(f)}e._load.call(e,h,h.params)}this._scenesNbCall[g]++}else{throw'Scene "'+g+"\" doesn't exist"}return e},exit:function(f){var e=this._scenesEnabled[f];if(e){e._exit.call(e);for(var g=0;g<this._scenesIndex.length;g++){if(this._scenesIndex[g]==f){this._scenesIndex.splice(g,1);break}}delete this._scenesEnabled[f]}},isEnabled:function(e){return this._scenesEnabled[e]?true:false},exitAll:function(f){var e;if(!(f instanceof Array)){f=[f]}for(e in this._scenesEnabled){if(_CanvasEngine.inArray(e,f)){this.exit(e)}}},exist:function(e){return this._scenes[e]?true:false},get:function(e){return this._scenes[e]},getEnabled:function(){return this._scenesEnabled},_loop:function(h){var f=this,g,i;this.fps=0;var l=new Date().getTime(),k;function e(){var n,m=0;k=(new Date().getTime()-l)/1000;l=new Date().getTime();f.fps=1/k;b.Sound._loop();h[m].clear();h[m]._ctxMouseEvent.clearRect(0,0,h[m].width,h[m].height);for(g=0;g<f._scenesIndex.length;g++){i=f._scenesEnabled[f._scenesIndex[g]];if(i){i._loop()}}requestAnimationFrame(e)}requestAnimationFrame(e)},getFPS:function(){return ~~this.fps},getPerformance:function(){return ~~(this.getFPS()/60*100)}}});Class.create("Canvas",{id:null,element:null,stage:null,ctx:null,_globalElements:{},_ctxTmp:null,_layerDOM:null,_layerParent:null,_ctxMouseEvent:null,width:0,height:0,mouseEvent:true,initialize:function(f){var u=this,r,m;this.id=f;var g=this._getElementById(f);if(g.tagName!="CANVAS"&&g.tagName!="canvas"){this.element=document.createElement("canvas");this._layerDOM=document.createElement("div");r=this.element.width=g.getAttribute("width");m=this.element.height=g.getAttribute("height");this.element.style.position="absolute";g.style.position=this._layerDOM.style.position="relative";g.style.width=r+"px";g.style.height=m+"px";g.style.overflow=this._layerDOM.style.overflow="hidden";this._layerDOM.style.width="100%";this._layerDOM.style.height="100%";g.appendChild(this.element);g.appendChild(this._layerDOM);this._layerParent=g}else{this.element=g}this.width=this.element.width;this.height=this.element.height;this.ctx=this.element.getContext("2d");this.hammerExist=typeof(Hammer)!=="undefined";this._mouseEvent();var t=["click","dbclick","mousemove","mousedown","mouseup"],q=["dragstart","drag","dragend","dragup","dragdown","dragleft","dragright","swipe","swipeup","swipedown","swipeleft","swiperight","rotate","pinch","pinchin","pinchout","tap","doubletap","hold","transformstart","transform","transformend","release","touch","release"];var p=this._layerParent||this.element;var n=null,k;if(this.hammerExist){n=new Hammer(p)}function o(h){p.addEventListener(h,function(i){s(i,h)},false)}function e(h){n.on(h,function(i){s(i,h)})}function s(B,z){var A,w,h=b.Scene.getEnabled(),v;if(B.gesture){A=B.gesture.touches}else{A=[u.getMousePosition(B)]}for(var i in h){v=h[i].getStage();for(var y=0;y<A.length;y++){k=A[y];if(k.pageX!==undefined){k=u.getMousePosition(k)}if(z=="mousemove"){if(u.mouseEvent){v._mousemove(B,k)}else{continue}}v.trigger(z,[B,k]);v._select(k,function(C){C.trigger(z,[B,k])})}}}if(n){for(var l=0;l<q.length;l++){e.call(this,q[l])}}for(var l=0;l<t.length;l++){o.call(this,t[l])}if(!d.contextmenu){p.addEventListener("contextmenu",function(h){h.preventDefault()})}},_elementsByScene:function(e,f,g){if(!this._globalElements[e]){this._globalElements[e]={}}if(!g){if(f){return this._globalElements[e][f]}return this._globalElements[e]}this._globalElements[e][f]=g},_getElementById:function(f){var e;if(d.cocoonjs){e=document.createElement("canvas");e.width=d.cocoonjs.width;e.height=d.cocoonjs.height;e.id=f;document.body.appendChild(e)}else{e=document.getElementById(f)}return e},_mouseEvent:function(){var e=document.createElement("canvas");e.width=this.width;e.height=this.height;this._ctxMouseEvent=e.getContext("2d")},canvasReady:function(){},getMousePosition:function(l){var k=this.element;var i=0;var h=0;while(k&&k.tagName!="BODY"){i+=k.offsetTop;h+=k.offsetLeft;k=k.offsetParent}if(l.clientX==undefined){l.clientX=l.pageX}if(l.clientY==undefined){l.clientY=l.pageY}if(!window.pageXOffset){window.pageXOffset=0}if(!window.pageYOffset){window.pageYOffset=0}var g=l.clientX-h+window.pageXOffset;var f=l.clientY-i+window.pageYOffset;return{x:g,y:f}},measureText:function(f,e,g){var h;g=g||"Arial";e=e||"12px";this.ctx.font="normal "+e+" "+g;h=this.ctx.measureText(f);this.ctx.font=null;return h},createPattern:function(f,e){e=e||"repeat";var g=b.Materials.get(f);if(!g){return}return this.ctx.createPattern(g,e)},createLinearGradient:function(f,h,e,g){return this.ctx.createLinearGradient(f,h,e,g)},createRadialGradient:function(h,k,g,f,i,e){return this.ctx.createRadialGradient(h,k,g,f,i,e)},addColorStop:function(f,e){return this.ctx.addColorStop(f,e)},getImageData:function(e,i,f,g){if(!e){e=0;i=0}if(!f){f=this.width;g=this.height}return this.ctx.getImageData(e,i,f,g)},putImageData:function(h,g,l,f,k,e,i){if(!g){g=0;l=0}return this.ctx.putImageData(h,g,l,f,k,e,i)},createImageData:function(){return this.ctx.createImageData.apply(this.ctx,arguments)},toDataURL:function(){return this.ctx.toDataURL()},clear:function(){return this.ctx.clearRect(0,0,this.width,this.height)},cursor:function(){function e(f){f.preventDefault();f.stopPropagation();f.target.style.cursor="move"}document.addEventListener("mousemove",e,false)},isFullscreen:function(){return document.fullscreen||document.mozFullScreen||document.webkitIsFullScreen},setSize:function(e,m,g){var i,n=this,l=this.element.width,h=this.element.height,k=e;if(e=="reset"){e=this._oldSize.width;m=this._oldSize.height;this.element.style.width=this.element.style.height=null;if(this._oldSize.type=="browser"){this.element.style.position=this.element.style.top=this.element.style.left=null}else{if(this._oldSize.type=="fullscreen"){document.cancelFullScreen()}}}else{if(e=="fullscreen"){g=m;e=screen.width;m=screen.height;if(this.element.requestFullScreen){this.element.requestFullScreen()}else{e=k="browser"}}}if(e=="browser"){g=m;e=window.innerWidth;m=window.innerHeight;var f=this.element;if(this._layerParent){f=this._layerParent}f.style.position="fixed";f.style.top=f.style.left=0;window.onresize=function(o){if(k=="browser"){n.setSize("browser",g)}}}if(g=="fit"){i=l/h;e=m*i;this.element.style.width=e+"px";this.element.style.height=m+"px"}else{if(g=="stretch"){this.element.style.width=e+"px";this.element.style.height=m+"px"}else{this.element.width=e;this.element.height=m}}if(this._layerParent){this._layerParent.style.width=e+"px";this._layerParent.style.height=m+"px"}this._oldSize={width:l,height:h,type:k};this.width=e;this.height=m;return this}});Class.create("Scene",{id:0,_stage:{},_events:[],_pause:false,_isReady:false,_index:0,model:null,initialize:function(g){var f,e=this;this.id=_CanvasEngine.uniqid();this._events=g.events},_loop:function(){if(this._isReady){if(this._pause){this._stage.refresh()}else{if(this.render){this.render.call(this,this._stage)}else{this._stage.refresh()}}}},emit:function(e,f){this.model.call(e,f)},getElement:function(e){if(this._global_elements[e]){return this._global_elements[e]}return this.createElement(e)},pause:function(e){if(e===undefined){return this._pause}this._pause=e;return this},togglePause:function(){return this.pause(!this._pause)},getStage:function(){return this._stage},getCanvas:function(e){if(!e){e=0}return b.el_canvas[e]},zIndex:function(f){var e;if(f===undefined){return this._index}if(f instanceof Class){f=f.zIndex()}e=b.Scene._scenesIndex.length;if(Math.abs(f)>=e){f=-1}if(f<0){f=e+f}_CanvasEngine.moveArray(b.Scene._scenesIndex,this._index,f);this._index=f;return this},createElement:function(f,k,e){if(f instanceof Array){var l={};for(var g=0;g<f.length;g++){l[f[g]]=this.createElement(f[g])}return l}if(typeof f!="string"){e=k;k=f}var h=b.Element["new"](this,null,k,e);h.name=f;return h},_exit:function(){this.getCanvas()._elementsByScene[this.name]={};if(this.exit){this.exit.call(this)}},loadEvents:function(){var e=this;if(_CanvasEngine.io&&this._events){_CanvasEngine.each(this._events,function(f,g){_CanvasEngine.io.on(e.name+"."+g,function(h){if(e[g]&&b.Scene.isEnabled(e.name)){e[g].call(e,h)}})})}},_load:function(h,u){var t=this;h=h||{};u=u||{};this._stage=b.Element["new"](this);this._index=b.Scene._scenesIndex.length-1;for(var k=0;k<b.el_canvas.length;k++){b.el_canvas[k].stage=this._stage}if(this.model){if(this._events){CE.each(this._events,function(v,w){t.model.on(w,function(i){t[w].call(t,i)})})}}this.loadEvents();var n=o("images"),e=o("sounds"),g=o("fonts"),l=o("videos"),f=o("data"),r=n+e+g+l+f,m=0;if(n>0){p("images")}if(e>0){p("sounds")}if(g>0){p("fonts")}if(l>0){p("videos")}if(f>0){p("data")}if(n==0&&e==0&&g==0&&l==0&&f==0){s()}function p(i){b.Materials.load(i,t.materials[i],function(){q()})}function q(){m++;if(t.preload){t.preload(t._stage,m/r*100)}if(r==m){s()}}function o(y){var w=0;if(!t.materials){return 0}if(t.materials[y]){for(var v in t.materials[y]){w++}}return w}function s(){if(h.when=="afterPreload"){b.Scene.exitAll(h.allExcept)}if(t.ready){t.ready(t._stage,t.getElement,u)}t._stage.trigger("canvas:readyEnd");if(t.model&&t.model.ready){t.model.ready.call(t.model)}t._isReady=true;if(h.transition){if(h.transition===true){h.transition={type:"fade"}}t.execTransition(h.transition.type,h.transition,h.overlay)}}},execTransition:function(p,l,h){var r=this,o;l=l||{};l=_CanvasEngine.extend({frames:30},l);var f=b.Scene.getEnabled(),m=0,n;for(var t in f){if(f[t].id==this.id){continue}n=f[t].getStage();o=f[t].getCanvas();switch(p){case"fade":if(!b.Timeline){throw"Add the Timeline class for transitions"}b.Timeline.New(n).to({opacity:0},l.frames).call(function(){if(!h){b.Scene.exitAll(r.name)}if(l.finish){l.finish.call(r)}f[t].zIndex(0)});break;case"image":var o=n.buffer(o.width,o.height),q=o.getContext("2d");var i=0;var g=new Worker("workers/transition.js");g.addEventListener("message",function(k){if(i==0){n.empty()}q.putImageData(k.data.imageData,0,0);n.drawImage(o);i++;if(k.data.finish){g.terminate();b.Scene.exitAll(r.name)}});var e=q.getImageData(0,0,o.width,o.height);g.postMessage({imgData:e,pattern:b.Materials.Transition.get(l.id)});n.on("canvas:refresh",function(k){g.postMessage("")});m++;break}}}});Class.create("Context",{_cmd:{},img:{},_useClip:false,globalAlpha:1,_PROPS:["shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","globalAlpha","globalCompositeOperation","lineJoin","lineWidth","miterLimit","fillStyle","font","textBaseline","strokeStyle"],alpha:function(e){},_setMethod:function(f,g){var e=this;this[f]=function(){var h=g=="cmd"?"_addCmd":"draw";e[h](f,arguments)}},_defaultRectParams:function(e,k,f,g,i){if(typeof e=="string"){this.fillStyle=e;e=k;k=f;f=g;g=i}if(e==undefined){e=0;k=0}if(f==undefined){f=this.width;g=this.height}return[e,k,f,g]},fillRect:function(e,i,f,g){this._addCmd("fillRect",this._defaultRectParams.apply(this,arguments),["fillStyle"])},fill:function(){this._addCmd("fill",[],["fillStyle"])},fillText:function(f,e,g){this._addCmd("fillText",[f,e,g],["fillStyle","font","textBaseline"])},strokeText:function(f,e,g){this._addCmd("strokeText",[f,e,g],["strokeStyle","font","textBaseline"])},strokeRect:function(e,i,f,g){this._addCmd("strokeRect",this._defaultRectParams.apply(this,arguments),["strokeStyle"])},stroke:function(){this._addCmd("stroke",[],["strokeStyle"])},drawImage:function(i,p,o,q,k,s,r,e,n){var l,f,h,m=i;if(!p){p=0}if(!o){o=0}if(typeof i==="string"){m=b.Materials.get(i);if(!m){return}this.img.width=m.width;this.img.height=m.height}if(/%$/.test(q)){s=p;r=o;p=0;o=0;q=m.width*parseInt(q)/100;k=m.height;e=q;n=k}var g=new RegExp("^"+window.location.origin,"g");if(!g.test(m.src)){h=m}else{h=b.Materials.createBuffer(i)}if(q!==undefined){l=[m,p,o,q,k,s,r,e,n];f=[h,p,o,q,k,s,r,e,n];this._buffer_img={params:f,x:s,y:r,width:e,height:n}}else{l=[m,p,o];f=[h,p,o];this._buffer_img={params:f,x:p,y:o,width:m.width,height:m.height}}this._addCmd("drawImage",l)},moveTo:function(){this._addCmd.call(this,"moveTo",arguments)},lineTo:function(){this._addCmd.call(this,"lineTo",arguments)},quadraticCurveTo:function(){this._addCmd.call(this,"quadraticCurveTo",arguments)},bezierCurveTo:function(){this._addCmd.call(this,"bezierCurveTo",arguments)},beginPath:function(){this._addCmd.call(this,"beginPath",arguments)},closePath:function(){this._addCmd.call(this,"closePath",arguments)},clip:function(){this._useClip=true;this._addCmd.call(this,"clip",arguments)},rect:function(){this._addCmd("rect",this._defaultRectParams.apply(this,arguments))},arc:function(){this._addCmd.call(this,"arc",arguments)},arcTo:function(){this._addCmd.call(this,"arcTo",arguments)},addColorStop:function(){this._addCmd.call(this,"addColorStop",arguments)},isPointInPath:function(){this._addCmd.call(this,"isPointInPath",arguments)},rotate:function(){this.draw.call(this,"rotate",arguments)},translate:function(){this.draw.call(this,"translate",arguments)},transform:function(){this.draw.call(this,"transform",arguments)},setTransform:function(){this.draw.call(this,"setTransform",arguments)},resetTransform:function(){this.draw.call(this,"resetTransform",arguments)},clearRect:function(){this.draw.call(this,"clearRect",arguments)},scale:function(){this.draw.call(this,"scale",arguments)},rotateDeg:function(e){this.rotate(e*Math.PI/180)},save:function(e){if(e){this._addCmd("save")}else{this.draw("save")}},restore:function(e){if(e){this._addCmd("restore")}else{this.draw("restore")}},clearPropreties:function(){var f=this._PROPS;for(var e=0;e<f.length;e++){if(this[f[e]]){this[f[e]]=undefined}}},_bufferEvent:function(f,e){var g=this._canvas[0]["_ctxMouseEvent"];if(this.hasEvent()||this._useClip){if(f=="drawImage"&&!this._forceEvent){g[f].apply(this._canvas[0]["_ctxMouseEvent"],this._buffer_img.params);g.globalCompositeOperation="source-atop";g.fillStyle="#"+this.color_key;g.fillRect(this._buffer_img.x,this._buffer_img.y,this._buffer_img.width,this._buffer_img.height)}else{g[f].apply(this._canvas[0]["_ctxMouseEvent"],e)}}},draw:function(g,m,q){var o="ctx",t;if(!m){m=[]}if(!q){q={}}var t=this.getScene().getCanvas()._ctxTmp;var k,f={};var i={};var h=true,p=1,e=false;var l=function(w,u,v){if(w[u]||this._forceEvent){this._canvas[0]["_ctxMouseEvent"][u]=v;return 0}return 1};if(g&&typeof g!="string"){t=g;g=null}if(g){f[g]={params:m,propreties:q};h=false}else{f=this._cmd}for(var r in f){k=f[r];for(var n=0;n<this._canvas.length;n++){i=k.propreties;if(h&&r=="restore"){this.clearPropreties()}if(i){for(var s in i){p=1;if(s=="globalAlpha"){i[s]=this.real_opacity}if(t){t[s]=i[s]}else{this._canvas[n][o][s]=i[s]}p&=l.call(this,i,"globalAlpha",1);p&=l.call(this,i,"strokeStyle","#"+this.color_key);p&=l.call(this,i,"fillStyle","#"+this.color_key);if(p){l.call(this,i,s,i[s])}}}if(t){t[r].apply(t,k.params)}else{this._canvas[n][o][r].apply(this._canvas[n][o],k.params);if(this._forceEvent){if(r=="rect"){this._bufferEvent("fillRect",k.params)}}this._bufferEvent(r,k.params)}}}},_addCmd:function(g,i,e){i=i||[];e=e||[];var l=this._PROPS;e=e.concat(l);var h={};for(var f=0;f<e.length;f++){if(this[e[f]]){h[e[f]]=this[e[f]]}}h.globalAlpha=1;this._cmd[g]={params:i,propreties:h}},hasCmd:function(e){return this._cmd[e]!==undefined},removeCmd:function(e){if(e=="clip"){this._useClip=false}delete this._cmd[e]}});Class.create("Element",{_children:[],_attr:{},x:0,y:0,real_x:0,real_y:0,real_scale_x:1,real_scale_y:1,real_rotate:0,real_skew_x:0,real_skew_y:0,real_opacity:1,real_propagation:true,scaleX:1,scaleY:1,skewX:0,skewY:0,opacity:1,rotation:0,width:null,height:null,regX:0,regY:0,parent:null,pause:false,_index:0,_id:null,_visible:true,_listener:{},_buffer_img:null,_out:1,_over:0,_nbEvent:0,_onRender:[],_pack:null,_forceEvent:false,propagationOpacity:null,initialize:function(k,g,h,e){this._id=_CanvasEngine.uniqid();this.width=h;this.height=e;this.scene=k;this.stage=k._stage;this.layer=g;var f,i=this.scene.getCanvas()._elementsByScene(this.scene.name);do{f=_CanvasEngine._getRandomColorKey()}while(f in i);this.color_key=f;this.scene.getCanvas()._elementsByScene(this.scene.name,f,this);this._canvas=b.el_canvas},_initParams:function(e){if(e||!this.parent){this.parent={scaleX:1,scaleY:1,real_x:0,real_y:0,real_scale_x:1,real_scale_y:1,real_rotate:0,real_skew_x:0,real_skew_y:0,real_opacity:1,real_propagation:true}}},refresh:function(){this._refresh(true,true);this._canvas._event_mouse=null},_refresh:function(l,g,e){if(this.stage._onRefresh){this.stage._onRefresh(this)}if(!this._visible){this._loop();return}if(!this.real_pause){this._initParams(l);this.real_propagation=this.parent.propagationOpacity==null?true:this.parent.propagationOpacity;this.save();this.real_scale_x=this.parent.real_scale_x*this.scaleX;this.real_scale_y=this.parent.real_scale_y*this.scaleY;this.real_y=(this.parent.real_y+this.y);this.real_x=(this.parent.real_x+this.x);this.real_skew_x=this.parent.real_skew_x+this.skewX;this.real_skew_y=this.parent.real_skew_y+this.skewY;this.real_rotate=this.parent.real_rotate+this.rotation;if(this.real_propagation){this.real_opacity=this.parent.real_opacity*this.opacity}else{this.real_opacity=this.opacity}this.real_pause=l?this.pause:this.parent.real_pause;this.globalAlpha=this.real_opacity;if(this.parent){if(this.parent.regX){this.regX=this.parent.regX}if(this.parent.regY){this.regY=this.parent.regY}}var k=this.real_x+this.regX;var h=this.real_y+this.regY;if(this.regX!=0||this.regY!=0){this.translate(k,h)}if(this.real_rotate!=0){this.rotateDeg(this.real_rotate)}if(this.real_scale_x!=1||this.real_scale_y!=1){this.scale(this.real_scale_x,this.real_scale_y)}if(this.real_skew_x!=0||this.real_skew_y!=0){this.transform(1,this.real_skew_x,this.real_skew_y,1,0,0)}if(this.regX!=0||this.regY!=0){this.translate(-k,-h)}this.translate(this.real_x,this.real_y)}this.draw(e);if(!this._useClip){this.restore()}if(g){if(!this.getScene()._pause){this._loop()}for(var f=0;f<this._children.length;f++){this._children[f]._refresh(false,true,e)}}if(this._useClip){this.restore()}},setX:function(e){this.x=e},setY:function(e){this.y=e},buffer:function(f,m){var l=this.children(),g=document.createElement("canvas"),e=g.getContext("2d"),o=this.getScene(),n=this.scene.getCanvas();g.width=f||n.width;g.height=m||n.height;this.scene.getCanvas()._ctxTmp=e;for(var k=0;k<l.length;k++){this._children[k]._refresh(true,true)}this.scene.getCanvas()._ctxTmp=null;return g},rotateTo:function(f,e){var g=parseInt(f);if(/rad$/.test(f)){g=g*180/Math.PI}this.rotation=e?360-g:g;this._stageRefresh();return this},setOriginPoint:function(e,f){if(e=="middle"){if(this.width&&this.height){e=Math.round(this.width/2);f=Math.round(this.height/2)}else{throw"Width and Height proprieties are not defined"}}if(e!==undefined){this.regX=+e}if(f!==undefined){this.regY=+f}return this},getScene:function(){return this.scene},_stageRefresh:function(){this.stage.refresh()},_mousemove:function(l,g){var f,k;for(var h=0;h<this._children.length;h++){f=this._children[h];k=g.x>f.real_x&&g.x<f.real_x+f.width&&g.y>f.real_y&&g.y<f.real_y+f.height;if(k){if(f._out==1){f._out++;f._out++;f._over=1;_trigger=f.trigger("mouseover",l)}if(_trigger){return}}else{if(f._over==1){f._out=1;f._over++;_trigger=f.trigger("mouseout",l)}}}},_select:function(g,i){var e,h;var f=this.scene.getCanvas();h=this._canvas[0]["_ctxMouseEvent"].getImageData(g.x,g.y,1,1).data;if(h[3]>0){e=f._elementsByScene(this.scene.name,_CanvasEngine.rgbToHex(h[0],h[1],h[2]));if(e){i(e)}}},_click:function(h,f,g){this._select(f,function(e){e.trigger("click",h,f)})},_cloneRecursive:function(g){var k,h;if(g._children.length>0){for(var f=0;f<g._children.length;f++){k=g._children[f];h=this.scene.createElement();for(var e in k){if(typeof e!="function"){h[e]=k[e]}}h.parent=g;this._cloneRecursive(k);g._children[f]=h}}},clone:function(){var f=this.scene.createElement();for(var e in this){if(typeof e!="function"){f[e]=this[e]}}this._cloneRecursive(f);return f},append:function(){var f;for(var e=0;e<arguments.length;e++){f=arguments[e];this._children.push(f);f.parent=this;f._index=this._children.length-1;f._refresh(false,true)}return arguments},prepend:function(e){this._children.push(e);e.parent=this;e.zIndex(0);return e},insertAfter:function(f){var e=f.parent.children();e.push(this);this._index=e.length-1;return this},children:function(g){var h=[],e=[];if(g){if(g instanceof Array){h=g}if(g instanceof Class){h=g.children()}for(var f=0;f<h.length;f++){e[f]=h[f].clone();e[f].parent=this}this._children=e}return this._children},detach:function(){this.remove();return this},pack:function(o,m,n){var f=this.children(),g=document.createElement("canvas"),p=g.getContext("2d"),l=this.getScene(),e;g.width=o;g.height=m;this.scene.getCanvas()._ctxTmp=p;for(var k=0;k<f.length;k++){this._children[k]._refresh(true,true)}this.scene.getCanvas()._ctxTmp=null;if(!n){this._pack=f}this.empty();e=l.createElement();e.drawImage(g);this.append(e);return this},unpack:function(){if(!this._pack){throw"Use the method pack before or impossible because you release the memory with method pack"}this._children=this._pack;this._pack=null;return this},forceEvent:function(f){if(f==undefined){f=true}this._forceEvent=f;if(!f){this.removeCmd("rect");return this}var e=this.width,g=this.height;if(!e){e=this.img.width}if(!g){g=this.img.height}if(!e||!g){throw"forceEvent() : Before, indicate the size of element !"}this.beginPath();this.rect(0,0,e,g);this.closePath();return this},isAppend:function(){return this in this.parent.children()},first:function(){return this.children()[0]},find:function(e){var g=this.children(),h=[];for(var f=0;f<g.length;f++){c=g[f];if(e==c.name){h.push(c)}}return h},findAttr:function(e,k){var h=this.children(),l,f;for(var g=0;g<h.length;g++){l=h[g];console.log(e,l.attr(e));f=l.attr(e);if(f){if(k!=undefined){if(f==k){return l}}else{return l}}}return false},zIndex:function(f){var e;if(f===undefined){return this._index}if(f instanceof Class){f=f.zIndex()}e=this.parent._children.length;if(Math.abs(f)>=e){f=-1}if(f<0){f=e+f}_CanvasEngine.moveArray(this.parent._children,this._index,f);this._index=f;this._stageRefresh();return this},zIndexBefore:function(e){this.zIndex(e.zIndex()-1);return this},remove:function(){var f;for(var e=0;e<this.parent._children.length;e++){f=this.parent._children[e];if(this._id==f._id){this.parent._children.splice(e,1);this._stageRefresh();return true}}return false},empty:function(){this._children=[];return this},attr:function(e,f){if(f===undefined){return this._attr[e]}this._attr[e]=f;return this},removeAttr:function(e){if(this._attr[e]){delete this._attr[e]}return this},offset:function(){return{left:this.x,top:this.y}},position:function(){return{left:this.real_x,top:this.real_y}},scaleTo:function(e){this.scaleX=e;this.scaleY=e;return this},css:function(m,k){var h={};var f;if(typeof m=="string"){h[m]=k}else{h=m}if(h.left){this.x=parseInt(h.left)}if(h.top){this.y=parseInt(h.top)}if(h["box-shadow"]){f=/^([0-9]+)(px)? ([0-9]+)(px)? ([0-9]+)(px)? (#[0-9a-fA-F]{6})$/.exec(h["box-shadow"]);if(f){this.shadowColor=f[7];this.shadowBlur=f[5];this.shadowOffsetX=f[1];this.shadowOffsetY=f[3]}}if(h["linear-gradient"]){f=/^\(([a-z ]+),[ ]*(.+)\)$/.exec(h["linear-gradient"]);if(f){var l=f[1];var e=f[2].split(",");this.createLinearGradient(0,0,0,0);for(var g=0;g<e.length;g++){f=/^(#[0-9a-fA-F]{6})[ ]+([0-9]{1,3})%$/.exec(e[g]);if(f){this.addColorStop(f[2]/100,f[1])}}}}if(h.opacity){this.opacity=h.opacity}this.stage.refresh();return this},hide:function(){this._visible=false},show:function(){this._visible=true},toggle:function(){if(this._visible){this.hide()}else{this.show()}},bind:function(e,f){this.on(e,f)},on:function(f,h){var g;f=f.split(" ");for(var e=0;e<f.length;e++){g=f[e];if(g=="canvas:refresh"){this.stage._onRefresh=h}else{if(g=="canvas:render"){this._onRender.push(h)}else{if(b.mobileUserAgent&&g=="click"){g="touch"}}}if(!this._listener[g]){this._listener[g]=[];this._nbEvent++}this._listener[g].push(h)}},unbind:function(e,f){this.off(e,f)},off:function(f,h){var g;f=f.split(" ");for(var e=0;e<f.length;e++){g=f[e];if(h){if(g=="canvas:render"){for(var e=0;e<this._onRender.length;e++){if(this._onRender[e]==h){this._onRender.splice(e,1);break}}}for(var e=0;e<this._listener[g].length;e++){if(this._listener[g][e]==h){this._listener[g].splice(e,1);break}}}else{if(g=="canvas:render"){this._onRender=[]}if(this._listener[g]){delete this._listener[g];this._nbEvent--}}if(this._listener[g]&&this._listener[g].length==0){delete this._listener[g];this._nbEvent--}}},eventExist:function(e){return this._listener[e]&&this._listener[e].length>0},hasEvent:function(){return this._nbEvent>0},trigger:function(k,m){var l,f=false;k=k.split(" ");if(!(m instanceof Array)){m=[m]}for(var g=0;g<k.length;g++){l=k[g];if(this._listener[l]){for(var h=0;h<this._listener[l].length;h++){f=true;if(this._listener[l][h]){this._listener[l][h].apply(this,m)}}}}return f},click:function(e){this.on("click",e)},dblclick:function(e){this.on("dblclick",e)},mouseover:function(e){this.on("mouseover",e)},mouseout:function(e){this.on("mouseout",e)},_loop:function(){for(var e=0;e<this._onRender.length;e++){if(this._onRender[e]){this._onRender[e].call(this)}}},addLoopListener:function(e){this.on("canvas:render",e)}}).extend("Context");Global_CE=b=Class["new"]("CanvasEngineClass");return b};CanvasEngine.Core=CanvasEngine;CanvasEngine.Class=Class;var CE=CanvasEngine;
|
|
12
|
-
/*! Hammer.JS - v1.0.3 - 2013-03-02
|
|
13
|
-
|
|
14
|
-
* http://eightmedia.github.com/hammer.js
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
* Copyright (c) 2013 Jorik Tangelder <j.tangelder@gmail.com>;
|
|
19
|
-
|
|
20
|
-
* Licensed under the MIT license */
|
|
21
|
-
(function(E){var y=function(P,O){return new y.Instance(P,O||{})};y.defaults={stop_browser_behavior:{userSelect:"none",touchCallout:"none",touchAction:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};y.HAS_POINTEREVENTS=navigator.pointerEnabled||navigator.msPointerEnabled;y.HAS_TOUCHEVENTS=("ontouchstart" in E);y.EVENT_TYPES={};y.DIRECTION_DOWN="down";y.DIRECTION_LEFT="left";y.DIRECTION_UP="up";y.DIRECTION_RIGHT="right";y.POINTER_MOUSE="mouse";y.POINTER_TOUCH="touch";y.POINTER_PEN="pen";y.EVENT_START="start";y.EVENT_MOVE="move";y.EVENT_END="end";y.plugins={};y.READY=false;function e(){if(y.READY){return}y.event.determineEventTypes();for(var O in y.gestures){if(y.gestures.hasOwnProperty(O)){y.detection.register(y.gestures[O])}}y.event.onTouch(document,y.EVENT_MOVE,y.detection.detect);y.event.onTouch(document,y.EVENT_END,y.detection.endDetect);y.READY=true}y.Instance=function(Q,P){var O=this;e();this.element=Q;this.enabled=true;this.options=y.utils.extend(y.utils.extend({},y.defaults),P||{});if(this.options.stop_browser_behavior){y.utils.stopDefaultBrowserBehavior(this.element,this.options.stop_browser_behavior)}y.event.onTouch(Q,y.EVENT_START,function(R){if(O.enabled){y.detection.startDetect(O,R)}});return this};y.Instance.prototype={on:function F(P,Q){var R=P.split(" ");for(var O=0;O<R.length;O++){this.element.addEventListener(R[O],Q,false)}return this},off:function o(P,Q){var R=P.split(" ");for(var O=0;O<R.length;O++){this.element.removeEventListener(R[O],Q,false)}return this},trigger:function J(O,Q){var P=document.createEvent("Event");P.initEvent(O,true,true);P.gesture=Q;this.element.dispatchEvent(P);return this},enable:function d(O){this.enabled=O;return this}};var I=null;var l=false;var h=false;y.event={bindDom:function(Q,S,R){var P=S.split(" ");for(var O=0;O<P.length;O++){Q.addEventListener(P[O],R,false)}},onTouch:function B(Q,P,R){var O=this;this.bindDom(Q,y.EVENT_TYPES[P],function(S){var T=S.type.toLowerCase();if(T.match(/mouseup/)&&h){h=false;return}if(T.match(/touch/)||(T.match(/mouse/)&&S.which===1)||(y.HAS_POINTEREVENTS&&T.match(/down/))){l=true}if(T.match(/touch|pointer/)){h=true}if(l&&!(h&&T.match(/mouse/))){if(y.HAS_POINTEREVENTS&&P!=y.EVENT_END){y.PointerEvent.updatePointer(P,S)}if(P===y.EVENT_END&&I!==null){S=I}else{I=S}R.call(y.detection,O.collectEventData(Q,P,S));if(y.HAS_POINTEREVENTS&&P==y.EVENT_END){y.PointerEvent.updatePointer(P,S)}}if(T.match(/up|cancel|end/)){l=false;I=null;y.PointerEvent.reset()}})},determineEventTypes:function H(){var O;if(y.HAS_POINTEREVENTS){O=y.PointerEvent.getEvents()}else{O=["touchstart mousedown","touchmove mousemove","touchend touchcancel mouseup"]}y.EVENT_TYPES[y.EVENT_START]=O[0];y.EVENT_TYPES[y.EVENT_MOVE]=O[1];y.EVENT_TYPES[y.EVENT_END]=O[2]},getTouchList:function t(O){if(y.HAS_POINTEREVENTS){return y.PointerEvent.getTouchList()}else{if(O.touches){return O.touches}else{return[{identifier:1,pageX:O.pageX,pageY:O.pageY,target:O.target}]}}},collectEventData:function M(Q,P,R){var S=this.getTouchList(R,P);var O=y.POINTER_TOUCH;if(R.type.match(/mouse/)||y.PointerEvent.matchType(y.POINTER_MOUSE,R)){O=y.POINTER_MOUSE}return{center:y.utils.getCenter(S),timestamp:R.timestamp||new Date().getTime(),target:R.target,touches:S,eventType:P,pointerType:O,srcEvent:R,preventDefault:function(){if(this.srcEvent.preventManipulation){this.srcEvent.preventManipulation()}if(this.srcEvent.preventDefault){this.srcEvent.preventDefault()}},stopPropagation:function(){this.srcEvent.stopPropagation()},stopDetect:function(){return y.detection.stopDetect()}}}};y.PointerEvent={pointers:{},getTouchList:function(){var O=this.pointers;var P=[];Object.keys(O).sort().forEach(function(Q){P.push(O[Q])});return P},updatePointer:function(P,O){if(P==y.EVENT_END){delete this.pointers[O.pointerId]}else{O.identifier=O.pointerId;this.pointers[O.pointerId]=O}},matchType:function(O,Q){if(!Q.pointerType){return false}var P={};P[y.POINTER_MOUSE]=(Q.pointerType==Q.MSPOINTER_TYPE_MOUSE||Q.pointerType==y.POINTER_MOUSE);P[y.POINTER_TOUCH]=(Q.pointerType==Q.MSPOINTER_TYPE_TOUCH||Q.pointerType==y.POINTER_TOUCH);P[y.POINTER_PEN]=(Q.pointerType==Q.MSPOINTER_TYPE_PEN||Q.pointerType==y.POINTER_PEN);return P[O]},getEvents:function(){return["pointerdown MSPointerDown","pointermove MSPointerMove","pointerup pointercancel MSPointerUp MSPointerCancel"]},reset:function(){this.pointers={}}};y.utils={extend:function i(O,Q){for(var P in Q){O[P]=Q[P]}return O},getCenter:function z(R){var S=[],Q=[];for(var P=0,O=R.length;P<O;P++){S.push(R[P].pageX);Q.push(R[P].pageY)}return{pageX:((Math.min.apply(Math,S)+Math.max.apply(Math,S))/2),pageY:((Math.min.apply(Math,Q)+Math.max.apply(Math,Q))/2)}},getVelocity:function p(O,Q,P){return{x:Math.abs(Q/O)||0,y:Math.abs(P/O)||0}},getAngle:function n(Q,P){var R=P.pageY-Q.pageY,O=P.pageX-Q.pageX;return Math.atan2(R,O)*180/Math.PI},getDirection:function k(Q,P){var O=Math.abs(Q.pageX-P.pageX),R=Math.abs(Q.pageY-P.pageY);if(O>=R){return Q.pageX-P.pageX>0?y.DIRECTION_LEFT:y.DIRECTION_RIGHT}else{return Q.pageY-P.pageY>0?y.DIRECTION_UP:y.DIRECTION_DOWN}},getDistance:function m(Q,P){var O=P.pageX-Q.pageX,R=P.pageY-Q.pageY;return Math.sqrt((O*O)+(R*R))},getScale:function w(P,O){if(P.length>=2&&O.length>=2){return this.getDistance(O[0],O[1])/this.getDistance(P[0],P[1])}return 1},getRotation:function u(P,O){if(P.length>=2&&O.length>=2){return this.getAngle(O[1],O[0])-this.getAngle(P[1],P[0])}return 0},isVertical:function C(O){return(O==y.DIRECTION_UP||O==y.DIRECTION_DOWN)},stopDefaultBrowserBehavior:function b(Q,P){var T,S=["webkit","khtml","moz","ms","o",""];if(!P||!Q.style){return}for(var O=0;O<S.length;O++){for(var R in P){if(P.hasOwnProperty(R)){T=R;if(S[O]){T=S[O]+T.substring(0,1).toUpperCase()+T.substring(1)}Q.style[T]=P[R]}}}if(P.userSelect=="none"){Q.onselectstart=function(){return false}}}};y.detection={gestures:[],current:null,previous:null,stopped:false,startDetect:function A(P,O){if(this.current){return}this.stopped=false;this.current={inst:P,startEvent:y.utils.extend({},O),lastEvent:false,name:""};this.detect(O)},detect:function r(R){if(!this.current||this.stopped){return}R=this.extendEventData(R);var S=this.current.inst.options;for(var Q=0,O=this.gestures.length;Q<O;Q++){var P=this.gestures[Q];if(!this.stopped&&S[P.name]!==false){if(P.handler.call(P,R,this.current.inst)===false){this.stopDetect();break}}}if(this.current){this.current.lastEvent=R}},endDetect:function D(O){this.detect(O);this.stopDetect()},stopDetect:function a(){this.previous=y.utils.extend({},this.current);this.current=null;this.stopped=true},extendEventData:function v(S){var T=this.current.startEvent;if(T&&(S.touches.length!=T.touches.length||S.touches===T.touches)){T.touches=[];for(var Q=0,O=S.touches.length;Q<O;Q++){T.touches.push(y.utils.extend({},S.touches[Q]))}}var P=S.timestamp-T.timestamp,V=S.center.pageX-T.center.pageX,U=S.center.pageY-T.center.pageY,R=y.utils.getVelocity(P,V,U);y.utils.extend(S,{deltaTime:P,deltaX:V,deltaY:U,velocityX:R.x,velocityY:R.y,distance:y.utils.getDistance(T.center,S.center),angle:y.utils.getAngle(T.center,S.center),direction:y.utils.getDirection(T.center,S.center),scale:y.utils.getScale(T.touches,S.touches),rotation:y.utils.getRotation(T.touches,S.touches),startEvent:T});return S},register:function f(P){var O=P.defaults||{};if(typeof(O[P.name])=="undefined"){O[P.name]=true}y.utils.extend(y.defaults,O);P.index=P.index||1000;this.gestures.push(P);this.gestures.sort(function(R,Q){if(R.index<Q.index){return -1}if(R.index>Q.index){return 1}return 0});return this.gestures}};y.gestures=y.gestures||{};y.gestures.Hold={name:"hold",index:10,defaults:{hold_timeout:500,hold_threshold:1},timer:null,handler:function L(O,P){switch(O.eventType){case y.EVENT_START:clearTimeout(this.timer);y.detection.current.name=this.name;this.timer=setTimeout(function(){if(y.detection.current.name=="hold"){P.trigger("hold",O)}},P.options.hold_timeout);break;case y.EVENT_MOVE:if(O.distance>P.options.hold_threshold){clearTimeout(this.timer)}break;case y.EVENT_END:clearTimeout(this.timer);break}}};y.gestures.Tap={name:"tap",index:100,defaults:{tap_max_touchtime:250,tap_max_distance:10,doubletap_distance:20,doubletap_interval:300},handler:function G(P,Q){if(P.eventType==y.EVENT_END){var O=y.detection.previous;if(P.deltaTime>Q.options.tap_max_touchtime||P.distance>Q.options.tap_max_distance){return}if(O&&O.name=="tap"&&(P.timestamp-O.lastEvent.timestamp)<Q.options.doubletap_interval&&P.distance<Q.options.doubletap_distance){y.detection.current.name="doubletap"}else{y.detection.current.name="tap"}Q.trigger(y.detection.current.name,P)}}};y.gestures.Swipe={name:"swipe",index:40,defaults:{swipe_max_touches:1,swipe_velocity:0.7},handler:function N(O,P){if(O.eventType==y.EVENT_END){if(P.options.swipe_max_touches>0&&O.touches.length>P.options.swipe_max_touches){return}if(O.velocityX>P.options.swipe_velocity||O.velocityY>P.options.swipe_velocity){P.trigger(this.name,O);P.trigger(this.name+O.direction,O)}}}};y.gestures.Drag={name:"drag",index:50,defaults:{drag_min_distance:10,drag_max_touches:1,drag_block_horizontal:false,drag_block_vertical:false,drag_lock_to_axis:false},triggered:false,handler:function s(O,P){if(y.detection.current.name!=this.name&&this.triggered){P.trigger(this.name+"end",O);this.triggered=false;return}if(P.options.drag_max_touches>0&&O.touches.length>P.options.drag_max_touches){return}switch(O.eventType){case y.EVENT_START:this.triggered=false;break;case y.EVENT_MOVE:if(O.distance<P.options.drag_min_distance&&y.detection.current.name!=this.name){return}y.detection.current.name=this.name;var Q=y.detection.current.lastEvent.direction;if(P.options.drag_lock_to_axis&&Q!==O.direction){if(y.utils.isVertical(Q)){O.direction=(O.deltaY<0)?y.DIRECTION_UP:y.DIRECTION_DOWN}else{O.direction=(O.deltaX<0)?y.DIRECTION_LEFT:y.DIRECTION_RIGHT}}if(!this.triggered){P.trigger(this.name+"start",O);this.triggered=true}P.trigger(this.name,O);P.trigger(this.name+O.direction,O);if((P.options.drag_block_vertical&&y.utils.isVertical(O.direction))||(P.options.drag_block_horizontal&&!y.utils.isVertical(O.direction))){O.preventDefault()}break;case y.EVENT_END:if(this.triggered){P.trigger(this.name+"end",O)}this.triggered=false;break}}};y.gestures.Transform={name:"transform",index:45,defaults:{transform_min_scale:0.01,transform_min_rotation:1,transform_always_block:false},triggered:false,handler:function q(Q,R){if(y.detection.current.name!=this.name&&this.triggered){R.trigger(this.name+"end",Q);this.triggered=false;return}if(Q.touches.length<2){return}if(R.options.transform_always_block){Q.preventDefault()}switch(Q.eventType){case y.EVENT_START:this.triggered=false;break;case y.EVENT_MOVE:var P=Math.abs(1-Q.scale);var O=Math.abs(Q.rotation);if(P<R.options.transform_min_scale&&O<R.options.transform_min_rotation){return}y.detection.current.name=this.name;if(!this.triggered){R.trigger(this.name+"start",Q);this.triggered=true}R.trigger(this.name,Q);if(O>R.options.transform_min_rotation){R.trigger("rotate",Q)}if(P>R.options.transform_min_scale){R.trigger("pinch",Q);R.trigger("pinch"+((Q.scale<1)?"in":"out"),Q)}break;case y.EVENT_END:if(this.triggered){R.trigger(this.name+"end",Q)}this.triggered=false;break}}};y.gestures.Touch={name:"touch",index:-Infinity,defaults:{prevent_default:false},handler:function g(O,P){if(P.options.prevent_default){O.preventDefault()}if(O.eventType==y.EVENT_START){P.trigger(this.name,O)}}};y.gestures.Release={name:"release",index:Infinity,handler:function K(O,P){if(O.eventType==y.EVENT_END){P.trigger(this.name,O)}}};if(typeof module==="object"&&typeof module.exports==="object"){module.exports=y}else{E.Hammer=y;if(typeof E.define==="function"&&E.define.amd){E.define("hammer",[],function(){return y})}}})(this);var Ease={linear:function(e,f,a,h,g){return h*(f/=g)+a},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,m,l){var i=1.70158;var k=0;var g=m;if(h==0){return e}if((h/=l)==1){return e+m}if(!k){k=l*0.3}if(g<Math.abs(m)){g=m;var i=k/4}else{var i=k/(2*Math.PI)*Math.asin(m/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*l-i)*(2*Math.PI)/k))+e},easeOutElastic:function(f,h,e,m,l){var i=1.70158;var k=0;var g=m;if(h==0){return e}if((h/=l)==1){return e+m}if(!k){k=l*0.3}if(g<Math.abs(m)){g=m;var i=k/4}else{var i=k/(2*Math.PI)*Math.asin(m/g)}return g*Math.pow(2,-10*h)*Math.sin((h*l-i)*(2*Math.PI)/k)+m+e},easeInOutElastic:function(f,h,e,m,l){var i=1.70158;var k=0;var g=m;if(h==0){return e}if((h/=l/2)==2){return e+m}if(!k){k=l*(0.3*1.5)}if(g<Math.abs(m)){g=m;var i=k/4}else{var i=k/(2*Math.PI)*Math.asin(m/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*l-i)*(2*Math.PI)/k))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*l-i)*(2*Math.PI)/k)*0.5+m+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}};Class.create("Timeline",{_timeline:{},_frequence:0,_stop:false,_propreties:[],_key_times:[],_onFinish:null,_varTime:{},initialize:function(a){this._frequence=0;this.el=a;this.addProprety(["opacity","x","y","scaleX","scaleY","rotation"]);this._loop()},to:function(a,e,d,b){if(d){a._ease_=d}if(!b){b="set"}this._key_times.push(e);this._timeline[e]=a;this._timeline[e]._cal=b;return this},wait:function(b){var a=this.getLastKey();this.to(a,b,false,"wait");return this},getLastKey:function(){var b=this._key_times[this._key_times.length-1];if(!b){var d={};for(var a=0;a<this._propreties.length;a++){d[this._propreties[a]]=this.el[this._propreties[a]]}return d}return this._timeline[b]},add:function(a,d,b){return this.to(a,d,b,"add")},addProprety:function(a){if(!(a instanceof Array)){a=[a]}for(var b=0;b<a.length;b++){this._propreties.push(a[b])}},loop:function(){var a=this;this.call(function(){a._stop=false;return true})},_initVar:function(){this._varTime={freq:this._frequence,time:0,time_tmp:0,last_t:0,next_t:0,find_next:false}},_loop:function(){var a=this,b;this.el.addLoopListener(function(){if(a._varTime.time===undefined){return}var e=a._varTime._frequence,f=a._varTime.time,h=a._varTime.time_tmp,n=a._varTime.last_t,m=a._varTime.next_t,p=a._varTime.find_next;function k(){var s={};for(var r=0;r<a._propreties.length;r++){s[a._propreties[r]]=this[a._propreties[r]]}a._timeline["0"]=s}function l(i){var s,r;if(a._timeline[m][i]===undefined){return this[i]}s=a._timeline[m]._cal;r=a._timeline[m][i];switch(s){case"add":r+=a._timeline[n][i];break}return r}function d(i){var v,s,u,r,t;if(a._timeline[m][i]===undefined){return this[i]}v=a._timeline[m]._ease_;u=a._timeline[m]._cal;t=a._timeline[m][i];switch(u){case"add":t+=a._timeline[n][i];break}if(!v){v=Ease.linear}s=v(t,(m-n)-h,a._timeline[n][i],t-a._timeline[n][i],m-n);return s}e=0;var q;if(a._stop){return}e++;if(e>=a._frequence){if(f==0){k.call(this)}if(h==0){p=false;for(var o in a._timeline){if(o>f){n=m?m:0;m=o;p=true;break}}if(!p){a._stop=true;f=0;n=0;h=0;if(a._onFinish){b=a._onFinish.call(this)}if(!b){return}else{k.call(this);m=0}}}h=m-f;if(h!=0){if(a._timeline[m]._cal!="wait"){if(h==1){for(var g=0;g<a._propreties.length;g++){this[a._propreties[g]]=l.call(this,a._propreties[g])}}else{for(var g=0;g<a._propreties.length;g++){this[a._propreties[g]]=d.call(this,a._propreties[g])}}}}f++}a._varTime._frequence=e;a._varTime.time=f;a._varTime.time_tmp=h;a._varTime.last_t=n;a._varTime.next_t=m;a._varTime.find_next=p})},call:function(a){this._initVar();this._onFinish=a;this._stop=false}});Class.create("Animation",{_images:[],_frames:{},_animations:{},_frequence:0,_stop:false,_timeline:null,_onFinish:null,_seq:null,_loop:false,_els:null,el:null,initialize:function(a){this._options=a;this._images=a.images;this._animations=a.animations;this._timeline=a.timeline;if(a.addIn){this.el=a.addIn.scene.createElement();a.addIn.append(this.el);this.add()}},add:function(d){if(d){this.el=d}var a=this;var b=0;var f=null;var e=0;this.stop();this.el.addLoopListener(function(){var v;var w=a._animations[a._seq],n=a._loop=="loop";function s(t){if(w.size){return w.size}var y=Global_CE.Materials.get(t);w.size={width:y.width,height:y.height}}if(w&&!w.frequence){w.frequence=0}if(f==null&&w){f=w.frequence}if(a._stop){if(w){f=w.frequence}b=0;return}f++;if(f>=w.frequence){if(a._images instanceof Array){var l=a._images[e];s(l);this.drawImage(l);e++;if(e>=a._images.length){e=0;if(!n){a._stop=true}}}else{var l=Global_CE.Materials.get(a._images),r=0,p=0;s(a._images);var u;var o=l.width/w.size.width;var m=l.height/w.size.height;var h;var i;function g(B,A){var y=a._images;if(w.patternSize){w.size={width:l.width/w.patternSize.width,height:l.height/w.patternSize.height}}p=parseInt(A/Math.round(l.width/w.size.width));r=(A%Math.round(l.width/w.size.width));var t=w.size.width*r,z=w.size.height*p;B.trigger("animation:draw",A);if(w.image){y=w.image}if(!w.position){w.position={}}if(!w.position.left){w.position.left=0}if(!w.position.top){w.position.top=0}B.drawImage(y,t,z,w.size.width,w.size.height,w.position.left,w.position.top,w.size.width,w.size.height)}function q(){if(a._loop=="stop"){if(w.finish){w.finish.call(a)}a.stop();return true}else{if(a._loop=="remove"){if(a._options.addIn){this.empty()}else{this.remove()}if(w.finish){w.finish.call(a)}a.stop();return true}}return false}if(w.frames[0] instanceof Array){if(w.frames[b]===undefined){b=0;if(q.call(this)){return}}this.empty();w.framesDefault=w.framesDefault||{};if(!w.framesDefault.x){w.framesDefault.x=0}if(!w.framesDefault.y){w.framesDefault.y=0}if(!w.framesDefault.zoom){w.framesDefault.zoom=100}if(!w.framesDefault.opacity){w.framesDefault.opacity=255}if(!w.framesDefault.rotation){w.framesDefault.rotation=0}if(!w.frames[b]){b++;return}for(var k=0;k<w.frames[b].length;k++){u=w.frames[b][k];if(u){i=this.scene.createElement(w.size.width,w.size.height);h=u.pattern-1;i.setOriginPoint("middle");i.x=u.x!=undefined?u.x:w.framesDefault.x;i.y=u.y!=undefined?u.y:w.framesDefault.y;i.scaleX=u.zoom!=undefined?u.zoom/100:w.framesDefault.zoom/100;i.scaleY=u.zoom!=undefined?u.zoom/100:w.framesDefault.zoom/100;i.opacity=u.opacity!=undefined?u.opacity/255:w.framesDefault.opacity/255;i.rotation=u.rotation!=undefined?u.rotation:w.framesDefault.rotation;g(i,h);this.append(i)}}}else{h=w.frames[0]+b;if(h>w.frames[1]){b=0;q.call(this);g(this,w.frames[0])}else{g(this,h)}}b++}f=0}})},stop:function(){this._stop=true},play:function(a,b){this._loop=b;this._seq=a;this._stop=false}});var Animation={Timeline:{New:function(){return this["new"].apply(this,arguments)},"new":function(a){return Class["new"]("Timeline",[a])}},Animation:{New:function(){return this["new"].apply(this,arguments)},"new":function(a){return Class["new"]("Animation",[a])}}};var Input={Input:{keyBuffer:[],cacheKeyBuffer:[],_keyFunctions:{},_keyPress:{},_keyUp:{},_keyType:{},_keyPressed:{},_lock:{},_rules:{},_key:function(d,b,f){if(typeof b=="function"){b(d)}else{if(b instanceof Array){for(var a=0;a<b.length;a++){if(d.which==b[a]){if(f){f(d)}}}}else{if(d.which==b){if(f){f(d)}}}}},press:function(b,a){this._press("keyPress",b,a);this.keyUp(b)},clearKeys:function(a){this.press(a,function(){})},keyDown:function(b,a){this._press("keyDown",b,a)},keyUp:function(e,b){var a=this;if(e instanceof Array){for(var d=0;d<e.length;d++){a._keyUp[e[d]]=b}}else{a._keyUp[e]=b}document.onkeyup=function(f){a._keyPress[f.which]=0;a._keyPressed[f.which]=false;if(a._keyUp[f.which]){a._keyUp[f.which](f)}}},_press:function(h,g,d){var a=this;if(typeof g=="string"){g=this._rules[g]}if(g instanceof Array){for(var f=0;f<g.length;f++){e(g[f],h)}}else{e(g,h)}if(this._lock.canvas){var b=this._lock.canvas;b.onkeydown=k;b.onfocus=function(i){document.onkeydown=function(){return false};if(a._lock.onFocus){a._lock.onFocus(i,b)}};b.onblur=function(i){document.onkeydown=null;if(a._lock.onBlur){a._lock.onBlur(i,b)}}}else{document.onkeydown=k}function k(i){if(!a._keyPress[i.which]){a._keyPress[i.which]=0}a._keyPress[i.which]++;if(a._keyPress[i.which]>1&&a._keyType[i.which]=="keyPress"){return}a._keyPressed[i.which]=true;if(a._keyFunctions[i.which]){a._keyFunctions[i.which](i)}}function e(l,i){a._keyType[l]=i;a._keyFunctions[l]=d}},reset:function(b){this._keyPressed={};if(b){for(var a=0;a<b.length;a++){this._keyFunctions[b[a]]=null}}else{this._keyFunctions={}}},lock:function(a,f,b,d){var e=document.getElementById(a);e.setAttribute("tabindex",1);if(f){e.focus();document.onkeydown=function(){return false}}this._lock.canvas=e;this._lock.onFocus=b;this._lock.onBlur=d},isPressed:function(b){if(!(b instanceof Array)){b=[b]}for(var a=0;a<b.length;a++){if(this._keyPressed[b[a]]){return true}}return false},addKey:function(b,a){Input[b]=a},memorize:function(){this.cacheKeyBuffer=this.keyBuffer},restore:function(){this.keyBuffer=this.cacheKeyBuffer},trigger:function(d,e,a){var f,b,g;if(e=="press"){this.trigger(d,"down");this.trigger(d,"up",a);return}if(this._lock.canvas){b=this._lock.canvas}else{b=document}if(document.createEventObject){f=document.createEventObject();f.keyCode=d;b.fireEvent("onkey"+e,f)}else{if(document.createEvent){f=document.createEvent("Events");f.initEvent("key"+e,true,true);f.which=d;b.dispatchEvent(f)}}if(a){g=document.getElementById(a.id+"-dom");g.focus()}},addRule:function(b,a){this._rules[b]=a},Gamepad:{_listener:{},gamepad:null,_onConnect:null,_onDisconnect:null,_connectState:false,init:function(a,b){this._onConnect=a;this._onDisconnect=b;return this},getState:function(a){this.gamepad=Gamepad.getStates()[a];if(this.gamepad&&!this._connectState){if(this._onConnect){this._onConnect()}this._connectState=true}else{if(!this.gamepad&&this._connectState){if(this._onDisconnect){this._onDisconnect()}this._connectState=false}}},addListener:function(e,d,f){var a=Input.Input;if(typeof d!="function"){var b=d;d=function(){a.trigger(b,"down")};f=function(){a.trigger(b,"up")}}this._listener[e]={onDown:d,onUp:f,state:false}},update:function(){this.getState(0);if(!this.gamepad){return}for(var a in this._listener){if(this.gamepad[a]==1&&!this._listener[a].state){if(this._listener[a].onDown){this._listener[a].onDown()}this._listener[a].state=true}else{if(this.gamepad[a]==0&&this._listener[a].state){if(this._listener[a].onUp){this._listener[a].onUp()}this._listener[a].state=false}}}}},accelerometer:function(b){if(window.DeviceOrientationEvent){window.addEventListener("deviceorientation",function(d){a(d.alpha,d.beta,d.gamma)},false)}else{if(window.OrientationEvent){window.addEventListener("MozOrientation",function(d){a(d.x,d.y,d.z)},false)}}function a(d,f,e){b(d,f,e)}}}};Input.A=65;Input.Z=90;Input.E=69;Input.Q=81;Input.Esc=27;Input.Enter=13;Input.Shift=16;Input.Ctrl=17;Input.Alt=18;Input.Space=32;Input.Back=8;Input.F1=112;Input.F2=113;Input.F11=122;Input.F12=123;Input.Left=37;Input.Up=38;Input.Right=39;Input.Bottom=40;(function(n,f){var o=(function(){var t=new n(255);for(var v=0;v<256;v++){t[v]=String.fromCharCode(v)}var w=new n(8),u=new n(8);for(var v=0;v<9;v++){w[v]=~((u[v]=Math.pow(2,v)-1)^255)}var B="",A=0,s=8,y=0,z=0;return{open:function(i){s=8;if(i!==f){z=i.length;y=0;B=i;A=B.charCodeAt(y)}else{A=0;B=""}},close:function(){if(A>0){B+=t[A]}return B},writeRaw:function(i){if(s!==8){B+=t[A];A=0;s=8}B+=i},readRaw:function(i){if(s!==8){y++;A=0;s=8}var D=B.substr(y,i);y+=i;A=B.charCodeAt(y);return D},write:function C(F,E){var G=E-s,D=s<E?s:E,i=s-D;if(G>0){A+=F>>G<<i}else{A+=F<<i}s-=D;if(s===0){B+=t[A];s=8;A=0;if(G>0){C(F&u[G],G)}}},read:function r(E){if(y>=z){return null}var G=E-s,D=s<E?s:E,i=s-D;var F=(A&w[s])>>i;s-=D;if(s===0){A=B.charCodeAt(++y);s=8;if(G>0){F=F<<G|r(G)}}return F}}})();var q=o.write,d=o.read,g=o.writeRaw,e=o.readRaw,l=o.open,p=o.close;function b(A,z){if(typeof A==="number"){var y=A!==(A|0),t=0;if(A<0){A=-A;t=1}q(1+y,3);if(y){var r=1,s=10;while(s<=A){r++;s*=10}r=(8-r)+1;A=Math.round(A*(1000000000/s));while(A/10===((A/10)|0)){A/=10;r--}}if(A<2){q(A,4)}else{if(A<16){q(1,3);q(A,4)}else{if(A<256){q(2,3);q(A,8)}else{if(A<4096){q(3,3);q(A>>8&255,4);q(A&255,8)}else{if(A<65536){q(4,3);q(A>>8&255,8);q(A&255,8)}else{if(A<1048576){q(5,3);q(A>>16&255,4);q(A>>8&255,8);q(A&255,8)}else{if(A<16777216){q(6,3);q(A>>16&255,8);q(A>>8&255,8);q(A&255,8)}else{q(7,3);q(A>>24&255,8);q(A>>16&255,8);q(A>>8&255,8);q(A&255,8)}}}}}}}q(t,1);if(y){q(r,4)}}else{if(typeof A==="string"){var u=A.length;q(3,3);if(u>65535){q(31,5);q(u>>24&255,8);q(u>>16&255,8);q(u>>8&255,8);q(u&255,8)}else{if(u>255){q(30,5);q(u>>8&255,8);q(u&255,8)}else{if(u>28){q(29,5);q(u,8)}else{q(u,5)}}}g(A)}else{if(typeof A==="boolean"){q(+A,5)}else{if(A===null){q(2,5)}else{if(A instanceof n){q(4,3);for(var v=0,u=A.length;v<u;v++){b(A[v])}if(!z){q(6,3)}}else{q(5,3);for(var w in A){b(w);b(A[w])}if(!z){q(6,3)}}}}}}}function m(i){l();b(i,true);q(0,3);q(3,2);return p()}var h=new n(16);for(var k=0;k<16;k++){h[k]=Math.pow(10,k)}function a(v){var z=[],t=-1,w,y,A,s,u=false,C,r,B;l(v);while(true){w=d(3);if(w===0){A=d(2);if(A===2){A=null}else{if(A<2){A=!!A}else{if(A===3){break}}}}else{if(w===1||w===2){switch(d(3)){case 0:A=d(1);break;case 1:A=d(4);break;case 2:A=d(8);break;case 3:A=(d(4)<<8)+d(8);break;case 4:A=(d(8)<<8)+d(8);break;case 5:A=(d(4)<<16)+(d(8)<<8)+d(8);break;case 6:A=(d(8)<<16)+(d(8)<<8)+d(8);break;case 7:A=(d(8)<<24)+(d(8)<<16)+(d(8)<<8)+d(8);break}if(d(1)){A=-A}if(w===2){A/=h[d(4)]}}else{if(w===3){var D=d(5);switch(D){case 31:D=(d(8)<<24)+(d(8)<<16)+(d(8)<<8)+d(8);break;case 30:D=(d(8)<<8)+d(8);break;case 29:D=d(8);break}A=e(D);if(u){C=A;u=false;continue}}else{if(w===4||w===5){u=w===5;A=u?{}:[];if(B===f){B=A}else{if(r){y[C]=A}else{y.push(A)}}y=z[++t]=A;r=!(y instanceof Array);continue}else{if(w===6){y=z[--t];u=r=!(y instanceof Array);continue}}}}}if(r){y[C]=A;u=true}else{if(y!==f){y.push(A)}else{return A}}}return B}if(typeof window==="undefined"){exports.encode=m;exports.decode=a}else{window.BISON={encode:m,decode:a}}})(Array);Marshal={_pointer:{},_cache:{},_stack_dump:[],_decode:function(b){if(navigator.appName=="Microsoft Internet Explorer"){try{return JSON.parse(b)}catch(a){}}else{return BISON.decode(b)}},_encode:function(b){if(navigator.appName=="Microsoft Internet Explorer"){try{return JSON.stringify(b)}catch(a){}}else{return BISON.encode(b)}},exist:function(a){return localStorage&&localStorage[a]},_recursiveData:function(g,f){var e,a={},d={},h;if(g instanceof Object){for(var k in g){h=g[k];if(typeof h!="function"){if(h instanceof Array){d[k]=[];for(var b=0;b<h.length;b++){d[k][b]=this._recursiveData(h[b],f)}}else{if(h instanceof Object){d[k]=this._recursiveData(h,f)}else{if(h!==undefined){d[k]=h}}}}}}else{if(typeof g!="function"&&g!==undefined){return g}}if(f=="load"){if(d.__name__){a=Class.New(g.__name__,false);for(var k in d){if(typeof a[k]!="function"){a[k]=d[k]}}}else{a=d}}else{a=d}return a},load:function(b){var e,a,d;if(this._pointer[b]===undefined){this._pointer[b]=0}if(this._cache[b]){e=this._cache[b]}else{if(localStorage){e=this._decode(localStorage[b])||[];this._cache[b]=e}}a=this._recursiveData(e[this._pointer[b]],"load");if(!Marshal.exist(b)){return false}this._pointer[b]++;return a},dump:function(b,d){var e=[],a={};if(typeof b=="number"||typeof b=="string"||b instanceof Array){a=b}else{a=this._recursiveData(b,"save")}this._stack_dump.push(a);if(localStorage){localStorage[d]=this._encode(this._stack_dump)}},remove:function(a){if(localStorage){localStorage.removeItem(a);return true}return false}};Class.create("Scrolling",{main_el:null,scroll_el:[],scene:null,freeze:false,initialize:function(d,b,a){this.scene=d;this.tile_h=b;this.tile_w=a},setMainElement:function(a){this.main_el=a},addScroll:function(a){if(!a.screen_x){a.screen_x=0}if(!a.screen_y){a.screen_y=0}if(!a.parallax_x){a.parallax_x=0}if(!a.parallax_y){a.parallax_y=0}this.scroll_el.push(a);if(this.main_el){this.setScreen(a)}return this.scroll_el[this.scroll_el.length-1]},setScreen:function(h,b,a){var d,i;if(!b&&this.main_el){b=this.main_el.x;a=this.main_el.y}var e=this.scene.getCanvas();if(b<=e.width/2){d=0}else{if(b+e.width/2>=h.width){d=-(h.width-e.width)}else{d=-(b-e.width/2+(e.width/2%this.tile_w))}}if(a<=e.height/2){i=0}else{if(a+e.height/2>=h.height){i=-(h.height-e.height)}else{i=-(a-e.height/2+(e.height/2%this.tile_h))}}h.element.x=d;h.element.y=i;var k=this.tile_w/h.speed;var g=this.tile_h/h.speed;h.element.x=Math.floor(h.element.x/k)*k;h.element.y=Math.floor(h.element.y/g)*g;h.screen_x=Math.abs(h.element.x);h.screen_y=Math.abs(h.element.y);var f=this._multipleScreen(h.speed,h.screen_x,h.screen_y);h.screen_x=f.x;h.screen_y=f.y;this.update()},_multipleScreen:function(d,a,f){var e=this.tile_w/d;var b=this.tile_h/d;a=Math.floor(a/e)*e;f=Math.floor(f/b)*b;return{x:a,y:f}},update:function(){var b,e;var f=this.scene.getCanvas();if(this.freeze){return}if(!this.main_el){return}for(var g=0;g<this.scroll_el.length;g++){b=this.scroll_el[g];e={x:b.element.x,y:b.element.y};b.screen_x=this.main_el.x-f.width/2+(f.width/2%this.tile_w);b.screen_y=this.main_el.y-f.height/2+(f.height/2%this.tile_h);var k=Math.abs(e.x);var h=Math.abs(e.y);var d=b.speed;var a=b.speed;if(b.parallax){if(b.screen_x!=b.parallax_x){if(b.screen_x>b.parallax_x){e.x-=d}else{e.x+=d}b.parallax_x=b.screen_x}if(b.screen_y!=b.parallax_y){if(b.screen_y>b.parallax_y){e.y-=a}else{e.y+=a}b.parallax_y=b.screen_y}}else{if(k!=b.screen_x){if(b.screen_x>k){if(k>b.screen_x-d){e.x=-b.screen_x}else{e.x-=d}}else{if(b.screen_x<k){if(k<b.screen_x+d){e.x=-b.screen_x}else{e.x+=d}}}}if(h!=b.screen_y){if(b.screen_y>h){if(h>b.screen_y-a){e.y=-b.screen_y}else{e.y-=a}}else{if(b.screen_y<h){if(h<b.screen_y+a){e.y=-b.screen_y}else{e.y+=a}}}}}if(b.block){if(e.x>0){b.screen_x=e.x=0}else{if(e.x+b.width<f.width){e.x=f.width-b.width;e.x=this._multipleScreen(b.speed,e.x,0).x;b.screen_x=Math.abs(e.x)}}if(e.y>0){b.screen_y=e.y=0}else{if(e.y+b.height<f.height){e.y=f.height-b.height;e.y=this._multipleScreen(b.speed,0,e.y).y;b.screen_y=Math.abs(e.y)}}}if(f.width<=b.width){b.element.x=e.x>>0}if(f.height<=b.height){b.element.y=e.y>>0}}},mouseScroll:function(f,e,d){d=d||{};if(e.height<f.height){f.append(e);return this}var a={};var b=this;e._forceEvent=true;f.beginPath();f.rect(0,0,f.width,f.height);f.clip();f.closePath();e.rect(0,0,e.width,e.height);e.on("dragstart",function(g){a=this.offset();a.time=new Date().getTime();if(d.dragstart){d.dragstart.call(this,g)}});e.on("drag",function(g){if(g.direction=="up"||g.direction=="left"){g.distance=-g.distance}var i=1,h;h=a.top+g.distance*i;if(h>=0){h=0;if(d.onTop){d.onTop.call(this,g)}}else{if(f.height>=(h+this.height)){h=-this.height+f.height;if(d.onBottom){d.onBottom.call(this,g)}}}this.y=h;if(d.drag){d.drag.call(this,g)}});e.on("dragend",function(g){if(d.dragend){d.dragend.call(this,g)}});f.append(e);return this}});var Scrolling={Scrolling:{New:function(){return this["new"].apply(this,arguments)},"new":function(d,b,a){return Class["new"]("Scrolling",[d,b,a])}}};Class.create("Spritesheet",{image:null,_set:{},initialize:function(a,b){this.image=a;if(b){this.set(b)}},set:function(m){var h,a,l,k,g,f;for(var b in m){if(b=="grid"){for(var e=0;e<m.grid.length;e++){for(var d=0;d<m.grid[e].set.length;d++){a=m.grid[e].set[d];h=m.grid[e];k=h.tile[1]*parseInt(d/Math.round(h.size[0]));l=h.tile[0]*(d%Math.round(h.size[0]));if(!h.reg){h.reg=[0,0]}g=h.reg[0];f=h.reg[1];this._set[a]=[l,k,h.tile[0],h.tile[1],0,g,f]}}}else{this._set[b]=m[b]}}},draw:function(e,i,b){b=b||{};var f=this._set[i];if(!f){throw"Spritesheet "+i+" don't exist"}var h=+(b.x||"0")-f[5],g=+(b.y||"0")-f[6],a=b.w||f[2],d=b.h||f[3];e.drawImage(this.image,f[0],f[1],f[2],f[3],h,g,a,d)},pattern:function(d,f,a){var e=this._set[f],b=Global_CE.Materials.cropImage(this.image,e[0],e[1],e[2],e[3]);pattern=d.getScene().getCanvas().createPattern(b,a);d.fillStyle=pattern}});var Spritesheet={Spritesheet:{New:function(){return this["new"].apply(this,arguments)},"new":function(a,b){return Class["new"]("Spritesheet",[a,b])}}};Class.create("Window",{border:null,width:0,height:0,bitmap:null,el:null,_content:null,_borders:{},_border_size:{width:0,height:0},initialize:function(e,d,a,b){this.width=d;this.height=a;this.border=b;this.scene=e;if(b){this.border_img=Global_CE.Materials.get(b);this._construct()}else{this.el=this.scene.createElement(this.width,this.height);this._content=this.scene.createElement();this.el.append(this._content)}},_construct:function(){if(!Global_CE.Spritesheet){throw"Add Spritesheet class to use windows"}var f=["corner_upleft","up","corner_upright","left","center","right","corner_bottomleft","bottom","corner_bottomright"],e,a;this.el=this.scene.createElement(this.width,this.height);this._border_size.width=this.border_img.width/3;this._border_size.height=this.border_img.height/3;this.spritesheet=Global_CE.Spritesheet["new"](this.border,{grid:[{size:[3,3],tile:[this._border_size.width,this._border_size.height],set:f}]});this._content=this.scene.createElement();for(var d=0;d<f.length;d++){a=f[d];e=this._borders[a]=this.scene.createElement();if(/^corner/.test(a)){this.spritesheet.draw(e,a)}else{this.spritesheet.pattern(e,a)}this.el.append(e)}this._borders.center.zIndex(0);this.el.append(this._content);this.size(this.width,this.height)},size:function(e,a){var f=this._border_size.width,d=this._border_size.height;function b(g){return(g<0?0:g)}this._borders.up.x=f-1;this._borders.up.fillRect(0,0,e+1-f*2,d);this._borders.corner_upright.x=e-f;this._borders.left.y=d;this._borders.left.fillRect(0,0,f,b(a-d*2));this._borders.right.x=e-f;this._borders.right.y=d;this._borders.right.fillRect(0,0,f,b(a-d*2));this._borders.corner_bottomleft.y=a-d;this._borders.bottom.x=f-1;this._borders.bottom.y=a-d;this._borders.bottom.fillRect(0,0,b(e+1-f*2),d);this._borders.corner_bottomright.x=e-f;this._borders.corner_bottomright.y=a-d;this._borders.center.x=this._content.x=f-1;this._borders.center.y=this._content.y=d;this._borders.center.fillRect(0,0,b(e+3-f*2),b(a-d*2));this.el.width=e;this.el.height=a;this.el.setOriginPoint("middle");return this},position:function(b,e){var a=this.scene.getCanvas(),d;if(b===undefined){return{x:this.el.x,y:this.el.y}}if(e===undefined){if(b=="middle"){this.el.x=a.width/2-this.width/2;this.el.y=a.height/2-this.height/2}else{if(b=="bottom"){this.el.x=a.width/2-this.width/2;this.el.y=a.height-this.height-(a.height*0.03)}else{if(b=="top"){this.el.x=a.width/2-this.width/2;this.el.y=a.height*0.03}else{if(d=b.match(/top+([0-9]+)/)){this.el.x=a.width/2-this.width/2;this.el.y=d[1]}else{if(d=b.match(/bottom-([0-9]+)/)){this.el.x=a.width/2-this.width/2;this.el.y=a.height-d[1]}}}}}}else{this.el.x=b;this.el.y=e}return this},setBackground:function(a,e,b){var d;if(!e){e=0}b=b||1;d=this._borders.center;d.x=e;d.y=e;d.fillStyle=a;d.opacity=b;d.fillRect(0,0,this.width-e*2,this.height-e*2);return this},getBox:function(){return this.el},getContent:function(){return this._content},open:function(a){a.append(this.el);return this},remove:function(){this.el.remove();return this},cursor:{array_elements:null,el:null,index:0,params:{},_enable:true,init:function(a,b,d){if(a instanceof Array){b=a;a=null}this.params=d||{};this.array_elements=b;this.el=a;this.update();return this},refresh:function(a,b){this.array_elements=a;this.setIndex(this.index,b);this.update();return this},remove:function(){this.el.remove();return this},assignKeys:function(e){var b=this;if(e){Global_CE.Input.reset()}Global_CE.Input.press([Input.Up],function(){if(!b._enable){return}b.setIndex(b.index-1)});Global_CE.Input.press([Input.Bottom],function(){if(!b._enable){return}b.setIndex(b.index+1)});function f(){if(!b._enable){return}var g=b.array_elements[b.index];if(b._select&&g){b._select.call(b,g)}}Global_CE.Input.press([Input.Enter],f);function a(g){var h=this.array_elements[g];if(h.width&&h.height&&this._enable){h.forceEvent();h.on("touch",function(){b.setIndex(g);b.update();f()})}}for(var d=0;d<this.array_elements.length;d++){a.call(this,d)}return this},getCurrentElement:function(){return this.array_elements[this.index]},setIndex:function(a,d){var b=this.array_elements.length;if(a<0){a=this.params.reverse?b-1:0}else{if(a>=b){a=this.params.reverse?0:b-1}}this.index=a;this.update(true);return true},update:function(a){if(this.el){if(this.array_elements.length==0){this.el.hide();return}else{this.el.show()}}var b=this.getCurrentElement(),d;if(b){d=b.position();if(this.el){this.el.x=d.left;this.el.y=d.top}if(a&&this._onchange&&this.array_elements.length>0){this._onchange.call(this,b)}}},enable:function(a){if(a!=undefined){this._enable=a;if(a){this.assignKeys()}else{Global_CE.Input.reset([Input.Enter,Input.Up,Input.bottom])}}return this._enable},change:function(a){this._onchange=a;return this},select:function(a){this._select=a;return this}}});var Window={Window:{New:function(){return this["new"].apply(this,arguments)},"new":function(e,d,a,b){return Class["new"]("Window",[e,d,a,b])}}};if(typeof exports!="undefined"){var CE=require("canvasengine").listen(),CanvasEngine=false,Class=CE.Class}Class.create("Point",{initialize:function(b,a){this.x=b;this.y=a}});Class.create("Polygon",{initialize:function(a){this.points=[];this.center=a},addPoint:function(a){this.points.push(a)},addAbsolutePoint:function(a){this.points.push({x:a.x-this.center.x,y:a.y-this.center.y})},getNumberOfSides:function(){return this.points.length},rotate:function(b){for(var d=0;d<this.points.length;d++){var a=this.points[d].x;var e=this.points[d].y;this.points[d].x=Math.cos(b)*a-Math.sin(b)*e;this.points[d].y=Math.sin(b)*a+Math.cos(b)*e}},containsPoint:function(a){var l=this.points.length;var n=a.x;var m=a.y;var g=new Array();for(var b=0;b<this.points.length;b++){g.push(this.points[b].x+this.center.x)}var f=new Array();for(var k=0;k<this.points.length;k++){f.push(this.points[k].y+this.center.y)}var e,d=0;var h=false;for(e=0,d=l-1;e<l;d=e++){if(((f[e]>m)!=(f[d]>m))&&(n<(g[d]-g[e])*(m-f[e])/(f[d]-f[e])+g[e])){h=!h}}return h},intersectsWith:function(g){var f=Class.New("Point");var v,p,n,m,l;var e,u;var b=null;var a=99999999;for(e=0;e<this.getNumberOfSides();e++){if(e==0){f.x=this.points[this.getNumberOfSides()-1].y-this.points[0].y;f.y=this.points[0].x-this.points[this.getNumberOfSides()-1].x}else{f.x=this.points[e-1].y-this.points[e].y;f.y=this.points[e].x-this.points[e-1].x}v=Math.sqrt(f.x*f.x+f.y*f.y);f.x/=v;f.y/=v;p=n=this.points[0].x*f.x+this.points[0].y*f.y;for(u=1;u<this.getNumberOfSides();u++){v=this.points[u].x*f.x+this.points[u].y*f.y;if(v>n){n=v}else{if(v<p){p=v}}}v=this.center.x*f.x+this.center.y*f.y;p+=v;n+=v;m=l=g.points[0].x*f.x+g.points[0].y*f.y;for(u=1;u<g.getNumberOfSides();u++){v=g.points[u].x*f.x+g.points[u].y*f.y;if(v>l){l=v}else{if(v<m){m=v}}}v=g.center.x*f.x+g.center.y*f.y;m+=v;l+=v;if(n<m||p>l){return false}else{var r=(n>m?n-m:l-p);if(r<a){a=r;b={x:f.x,y:f.y}}}}for(e=0;e<g.getNumberOfSides();e++){if(e==0){f.x=g.points[g.getNumberOfSides()-1].y-g.points[0].y;f.y=g.points[0].x-g.points[g.getNumberOfSides()-1].x}else{f.x=g.points[e-1].y-g.points[e].y;f.y=g.points[e].x-g.points[e-1].x}v=Math.sqrt(f.x*f.x+f.y*f.y);f.x/=v;f.y/=v;p=n=this.points[0].x*f.x+this.points[0].y*f.y;for(u=1;u<this.getNumberOfSides();u++){v=this.points[u].x*f.x+this.points[u].y*f.y;if(v>n){n=v}else{if(v<p){p=v}}}v=this.center.x*f.x+this.center.y*f.y;p+=v;n+=v;m=l=g.points[0].x*f.x+g.points[0].y*f.y;for(u=1;u<g.getNumberOfSides();u++){v=g.points[u].x*f.x+g.points[u].y*f.y;if(v>l){l=v}else{if(v<m){m=v}}}v=g.center.x*f.x+g.center.y*f.y;m+=v;l+=v;if(n<m||p>l){return false}else{var r=(n>m?n-m:l-p);if(r<a){a=r;b={x:f.x,y:f.y}}}}function h(i,k){return{x:k.x+i.center.x,y:k.y+i.center.y}}var y,w,q=[],d=[],t=0;function s(C,o,k){var B,A,z,i,D=[];for(B=0;B<g.getNumberOfSides();B++){A=h(g,g.points[B]);z=h(g,g.points[B+1]?g.points[B+1]:g.points[0]);i=Polygon.intersectLineLine(o,k,A,z);if(i=="Coincident"){D.push({sides:B})}d[t].push(i)}t++;return D}for(u=0;u<this.getNumberOfSides();u++){d[t]=[];y=h(this,this.points[u]);w=h(this,this.points[u+1]?this.points[u+1]:this.points[0]);q.push(s(null,y,w))}return{overlap:a+0.001,axis:b,lines:d,coincident:q}}});var Polygon={};Polygon.intersectLineLine=function(f,d,k,i){var g=(i.x-k.x)*(f.y-k.y)-(i.y-k.y)*(f.x-k.x);var h=(d.x-f.x)*(f.y-k.y)-(d.y-f.y)*(f.x-k.x);var e=(i.y-k.y)*(d.x-f.x)-(i.x-k.x)*(d.y-f.y);if(e!=0){var b=g/e;var a=h/e;if(0<=b&&b<=1&&0<=a&&a<=1){return{x:f.x+b*(d.x-f.x),y:f.y+b*(d.y-f.y)}}else{return false}}else{if(g==0||h==0){return"Coincident"}else{return"Parallel"}}};Class.create("EntityModel",{x:0,y:0,_memorize:{x:0,y:0},hitState:{over:0,out:0},_polygon:{},_frame:"0",position:function(a,d){if(a!==undefined&&d!==undefined){this.x=a;this.y=d;var b=this._polygon[this._frame];if(b){b.center.x=this.x;b.center.y=this.y}}return{x:this.x,y:this.y}},savePosition:function(){this._memorize.x=this.x;this._memorize.y=this.y},restorePosition:function(){this.x=this._memorize.x;this.y=this._memorize.y},polygon:function(d){if(d instanceof Array){d={"0":d}}for(var b in d){this._polygon[b]=Class.New("Polygon",[{x:d[b][0][0],y:d[b][0][1]}]);for(var a=0;a<d[b].length;a++){this._polygon[b].addPoint({x:d[b][a][0],y:d[b][a][1]})}}},rect:function(a,e,b,d){if(!b&&!d){b=a;d=e;a=0;e=0}if(!d){d=b}this.polygon([[a,e],[a+b,e],[a+b,e+d],[a,e+d]])},hit:function(b){var a=this._polygon[this._frame].intersectsWith(b._polygon[b._frame]);this.hitState.result=a;if(a){this.hitState.out=0;this.hitState.over++}else{if(this.hitState.over>0){this.hitState.out=1;this.hitState.over=0}else{this.hitState.out=0;this.hitState.over=0}}return this.hitState},getPoints:function(a){a=a||this._frame;return this._polygon[a].points},getPolygonReg:function(a){a=a||this._frame;return this._polygon[a].center},getPolygon:function(a){a=a||this._frame;return this._polygon[a]},frame:function(a){if(a){this._frame=a}return this._frame},});Class.create("Entity",{stage:null,params:{},el:null,mode:null,hit_entities:[],initialize:function(b,d,a){if(a===undefined){a=true}this.stage=b;this.params=d;this.el=this.stage.getScene().createElement();if(a){this.setModel(Class.New("EntityModel"))}this.testHit()},setModel:function(a){this.model=a},position:function(a,e,b){var d=this.model.position(a,e);if(a!==undefined){this.el.x=d.x;this.el.y=d.y}return{x:d.y,y:d.y}},move:function(a,d){var b=this.model.position();if(!a){a=0}if(!d){d=0}return this.position(a+b.x,d+b.y,true)},polygon:function(a){this.model.polygon(a)},rect:function(a,e,b,d){this.model.rect(a,e,b,d);this.el.width=b;this.el.height=d},onHit:function(a,b,d){this.hit_entities=this.hit_entities.concat(b);this.el.on("entity:hit:"+a,d)},testHit:function(){var a=this;this.el.attr("entity:testHit",function(){a.hit(a.hit_entities)})},testAnimHit:function(){var a=this;this.el.on("animation:draw",function(b){})},hit:function(f,g){var e,a=this;function b(h){if(g){g.call(a,h,a.el)}a.el.trigger("entity:hit:"+h,[a.el])}for(var d=0;d<f.length;d++){e=this.model.hit(f[d].model);if(e.over==1){b("over")}else{if(e.out==1){b("out")}}}}});var Matrix={};Class.create("Grid",{_rows:0,_cols:0,cell:{width:0,height:0,prop:[],},_matrix:null,_transform:null,_func:null,initialize:function(a,b){if(a instanceof Array){this._matrix=a;this.cell.prop=a;b=a[0].length;a=a.length}this._rows=a;this._cols=b},transform:function(a){this._func=a},convert:function(a,b){if(!this._func){return{x:a,y:b}}return this._func.call(this,a,b)},setPropertyCell:function(a){if(typeof(PF)!="undefined"){this._pf_grid=false;this._pf_prop=(CanvasEngine||CE.Core).rotateMatrix(a)}this.cell.prop=a},getPropertyByCell:function(a,b){if(!this.cell.prop[a]){return undefined}return this.cell.prop[a][b]},setPropertyByCell:function(a,b,d){if(!this.cell.prop[a]){return undefined}this.cell.prop[a][b]=d;if(typeof(PF)!="undefined"){this._pf_grid=false;this._pf_prop=(CanvasEngine||CE.Core).rotateMatrix(this.cell.prop)}return this},getPropertyByPos:function(b,d){var a=this.getCellByPos(b,d);return this.getPropertyByCell(a.col,a.row)},testCell:function(l,h,f){f=f||{};if(!h.getPolygon){h=h.model}var n=[],b=h.getPolygon(),m=this;function g(o,p){return{x:p.x+o.center.x,y:p.y+o.center.y}}function e(v,q,p,o){var t,z,w,B=[],s=0,A,r=[],y=null,u={};for(t=0;t<o.getNumberOfSides();t++){z=g(o,o.points[t]);w=g(o,o.points[t+1]?o.points[t+1]:o.points[0]);A=Polygon.intersectLineLine(q,p,z,w);if(A=="Coincident"){if(q.x==z.x&&q.y==z.y){y={x:q.x,y:q.y}}else{if(p.x==w.x&&p.y==w.y){y={x:p.x,y:p.y}}else{if(q.x==w.x&&q.y==w.y){y={x:q.x,y:q.y}}else{if(p.x==z.x&&p.y==z.y){y={x:p.x,y:p.y}}}}}r.push({sides:t,points:y})}}if(true){return r}else{u[v]=r;return u}}function k(o){return{x:o.x*m.cell.width,y:o.y*m.cell.height}}if(!l.getPolygon){h=h.model}var i=[{y:l.row,x:l.col},{y:l.row,x:l.col+1},{y:l.row+1,x:l.col+1},{y:l.row+1,x:l.col}];var d,a;for(j=0;j<i.length;j++){d=k(i[j]);a=k(i[j+1]?i[j+1]:i[0]);n.push(e(null,d,a,b))}return n},getEntityCells:function(k,g){var l,h,d,q,e,a,n,m,b=[],s={min_x:99999999,max_x:0,min_y:99999999,max_y:0};g=g||{};if(k.model){q=k.model.getPoints();e=k.model.getPolygonReg();a=k.model.getPolygon()}else{q=k.getPoints();e=k.getPolygonReg();a=k.getPolygon()}for(l=0;l<q.length;l++){d=q[l];n=d.x+e.x;m=d.y+e.y;if(n<s.min_x){s.min_x=n}if(n>s.max_x){s.max_x=n}if(m<s.min_y){s.min_y=m}if(m>s.max_y){s.max_y=m}}var o=[this.getCellByPos(s.min_x,s.min_y),this.getCellByPos(s.max_x,s.min_y),this.getCellByPos(s.max_x,s.max_y),this.getCellByPos(s.min_x,s.max_y)];var f=o[2].row-o[0].row,r=o[1].col-o[0].col;for(l=0;l<r-1;l++){for(h=0;h<f-1;h++){o.push({row:o[0].row+h,col:o[0].col+l})}}return{cells:o}},getCellByPos:function(a,e){if(this.cell.width==0||this.cell.height==0){throw"Set the size of the cell prior with setCellSize method"}var b=Math.floor(this.convert(a,e).x/this.cell.width),d=Math.floor(this.convert(a,e).y/this.cell.height);return{col:b,row:d}},setCellSize:function(a,b){this.cell.width=a;this.cell.height=b},getRows:function(){return this._rows},getCols:function(){return this._cols},getNbCell:function(){return this.getRows()*this.getCols()},passableCell:function(h,g,s,o){o=o||[];var k=this._cols;var w=this._rows;var m=this.cell.prop;var p=[];function d(){for(var D=0;D<k*2+1;D++){p[D]=[];for(var C=0;C<k*2+1;C++){p[D][C]=-1}}var y=Math.floor(p.length/2);p[y][y]=0}var z=[];var b=[[h,g]];var l=0;var f=b[0][0]-k;var e=b[0][1]-k;var A=[];var n=0;d();function v(i,D){for(var C=0;C<o.length;C++){if(o[C][0]==i&&o[C][1]==D){return true}}return false}while(!b.length==0&&l<s){z=[];for(var r=0;r<b.length;r++){var u=b[r][0];var t=b[r][1];var a=u;var B=t;for(var q=0;q<4;q++){switch(q){case 0:if(m[u][t+1]!=undefined&&m[u][t+1]==n&&!v(u,t+1)&&p[a][B+1]==-1){z.push([u,t+1]);A.push([u,t+1]);p[a][B+1]=0}break;case 1:if(m[u+1]!=undefined&&m[u+1][t]!=undefined&&m[u+1][t]==n&&!v(u+1,t)&&p[a+1][B]==-1){z.push([u+1,t]);A.push([u+1,t]);p[a+1][B]=0}break;case 2:if(m[u][t-1]!=undefined&&m[u][t-1]==n&&!v(u,t-1)&&p[a][B-1]==-1){z.push([u,t-1]);A.push([u,t-1]);p[a][B-1]=0}break;case 3:if(m[u-1]!=undefined&&m[u-1][t]!=undefined&&m[u-1][t]==n&&!v(u-1,t)&&p[a-1][B]==-1){z.push([u-1,t]);A.push([u-1,t]);p[a-1][B]=0}break}}}b=z;l+=1}return A},pathfinding:function(d,g,b,f,e,a){e=e||"AStarFinder";if(!this._pf_grid){this._pf_grid=new PF.Grid(this._rows,this._cols,this._pf_prop)}if(d===undefined){return this._pf_grid}return new PF[e](a).findPath(d,g,b,f,this._pf_grid.clone())}});var Hit={Grid:{"new":function(a,b){return Class.New("Grid",[a,b])}}};if(typeof exports!="undefined"){exports.Class=Hit}Class.create("Effect",{scene:null,el:null,canvas:null,initialize:function(b,a){this.scene=b;this.el=a;this.canvas=this.scene.getCanvas();if(!Global_CE.Timeline){throw"Add Timeline class to use effects"}return this},screenFlash:function(a,f,g){var d=this.scene.createElement(),b=this.scene.getCanvas();d.fillStyle=a;d.fillRect(0,0,b.width,b.height);d.opacity=0.8;this.scene.getStage().append(d);d.zIndex(-1);var e=Global_CE.Timeline["new"](d);e.to({opacity:"0"},f).call(function(){d.remove();if(g){g()}})},blink:function(d,b,f){var e=0;var a=function(){d--;e++;if(e>=b){e=0;this.toggle()}if(d<=0){this.off("canvas:render",a);this.show();if(f){f()}}};this.el.on("canvas:render",a)},shake:function(d,e,h,b,i){if(typeof b=="function"){i=b;b=false}var g=0,f=1;b=b||"x";var a=function(){var k=(d*e*f)/10;if(h<=1&&g*(g+k)<0){g=0}else{g+=k}if(g>d*2){f=-1}if(g<-d*2){f=1}if(h>=1){h-=1}if(/x/.test(b)){this.x=g}if(/y/.test(b)){this.y=g}if(h==0){this.off("canvas:render",a);if(i){i()}}console.log(k)};this.el.on("canvas:render",a)},changeScreenColorTone:function(a,e,g,d,f){var b=false;if(this.tone){this.tone.remove();delete this.tone;b=true;if(a=="reset"){return}}this.tone=this.scene.createElement(),canvas=this.scene.getCanvas();this.tone.fillStyle=a;this.tone.fillRect(0,0,canvas.width,canvas.height);this.tone.opacity=0;this.tone.globalCompositeOperation=g;this.scene.getStage().append(this.tone);this.tone.zIndex(-1);if(!b){this.tone.opacity=0;if(e>0){Global_CE.Timeline["new"](this.tone).to({opacity:d},e).call(f)}else{this.tone.opacity=d}}}});var Effect={Effect:{New:function(){return this["new"].apply(this,arguments)},"new":function(b,a){return Class["new"]("Effect",[b,a])}}};Class.create("Text",{scene:null,text:"",el:null,_family:null,_style:{size:"20px",family:"Arial",weight:"normal",style:"normal",variant:"normal",color:"#000",transform:"none",decoration:"none",border:"none",lineHeight:25,shadow:null,textBaseline:"alphabetic",lineWidth:null},lines:[],initialize:function(a,b){this.scene=a;this.construct(b)},construct:function(a){a=""+a;this.el=this.scene.createElement();a=this._transformHTML(a);this.text=a.split("\n");this.lines=[]},_transformHTML:function(a){a=a.replace(/<br>/g,"\n");return a},setImageText:function(d,g,b,a){var e=this.scene.createElement();if(!Global_CE.Spritesheet){throw"Add Spritesheet class to use setImageText method"}a=a||{rows:1,cols:1};var f=Global_CE.Spritesheet.New(d,{grid:[{size:a,tile:[b.width,b.height],set:g}]});this._family=f},style:function(b){if(b.size&!b.lineHeight){b.lineHeight=b.size}for(var a in b){this._style[a]=b[a]}return this},draw:function(k,m,l,t){if(t&&!Global_CE.Timeline){throw"Add Timeline class to use effects"}if(!t){t={}}if(!m){m=0}if(!l){l=0}var q=this._style,B,p,A,a=0,h,g="",f;var d=this.scene.getCanvas(),u=this;this.el.x=m;this.el.y=l;function C(s,i,n){h=parseInt(q.lineHeight);h*=parseInt(q.size)/20;a=h*s;i.font=q.style+" "+q.weight+" "+q.variant+" "+q.size+" "+q.family;i.fillStyle=q.color;i.textBaseline=q.textBaseline;if(q.shadow){f=q.shadow.match(/(-?[0-9]+) (-?[0-9]+) ([0-9]+) ([#a-zA-Z0-9]+)/);if(f){i.shadowOffsetX=f[1];i.shadowOffsetY=f[2];i.shadowBlur=f[3];i.shadowColor=f[4]}}i.fillText(n,0,a);if(q.border!="none"){B=q.border.match(/([0-9]+)px ([#a-zA-Z0-9]+)/);i.font=q.style+" "+q.weight+" "+q.variant+" "+(q.size+B[1])+" "+q.family;i.strokeStyle=B[2];i.strokeText(n,0,a)}return i}function r(s,n){var i=u.scene.createElement();C(s,i,n);u.lines.push({text:n,el:i,chars:[]});i.opacity=0}function b(J,n,G){var K=this.lines[J].el;if(n>=this.lines[J].text.length){G();for(var F=0;F<this.lines[J].chars.length;F++){this.lines[J].chars[F].el.remove()}this.el.append(K);K.opacity=1;this.lines[J].el.opacity=1;if(t._char.onFinish){t._char.onFinish()}return}var y=this.scene.createElement(),H=this.lines[J].text[n],s=d.measureText(H).width,I=this;C(J,y,H);y.x=n*s;y.opacity=0;this.el.append(y);this.lines[J].chars.push({_char:H,el:y});Global_CE.Timeline["new"](y).to({opacity:1},t._char.frames).call(function(){if(t._char.onEffect){t._char.onEffect(H,y)}b.call(I,J,n+1,G)})}function z(s){var i=this,n;if(s>=this.lines.length){if(t.line&&t.line.onFinish){t.line.onFinish()}return}n=this.lines[s].el;if(t.line){this.el.append(n);Global_CE.Timeline["new"](n).to({opacity:1},t.line.frames).call(function(){if(t.line.onEffect){t.line.onEffect(i.lines[s].text,n)}z.call(i,s+1)})}else{if(t._char){b.call(this,s,0,function(){z.call(i,s+1)})}else{n.opacity=1;this.el.append(n);z.call(this,s+1)}}}var A,E,o,v,e=0;for(var D=0;D<this.text.length;D++){p=this.text[D];if(q.lineWidth){o=d.measureText(p,q.size,q.family).width;g="";v=p.split(" ");for(var w=0;w<v.length;w++){E=g+v[w]+" ";A=d.measureText(E,q.size,q.family);o=A.width;if(o>q.lineWidth){r(e,g);g=v[w]+" ";e++}else{g=E}}if(o<q.lineWidth){r(e,g);e++}}else{r(D,p)}}z.call(this,0);k.append(this.el);this.parent=k;this.pos={x:m,y:l};return this},refresh:function(a){if(!this.parent){throw"Use 'draw' method before"}this.parent.empty();this.construct(a);this.draw(this.parent,this.pos.x,this.pos.y);return this},getNumberLines:function(){return this.lines.length}});var Text={Text:{New:function(){return this["new"].apply(this,arguments)},"new":function(a,b){return Class["new"]("Text",[a,b])}}};
|