diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index 0338e9e1..ae679185 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -22,11 +22,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 64 +Version: 0.3 build: 212 Created on: -DATE: 2012-02-09 -TIME: 20:34:37 +DATE: 2012-02-23 +TIME: 17:37:53 */ diff --git a/build/caat-box2d.js b/build/caat-box2d.js index b235cae5..572d179f 100644 --- a/build/caat-box2d.js +++ b/build/caat-box2d.js @@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 65 +Version: 0.3 build: 213 Created on: -DATE: 2012-02-09 -TIME: 20:35:01 +DATE: 2012-02-23 +TIME: 17:38:27 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index 679e56b2..5495382a 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -22,15 +22,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 64 +Version: 0.3 build: 212 Created on: -DATE: 2012-02-09 -TIME: 20:34:37 +DATE: 2012-02-23 +TIME: 17:37:53 */ -var CAAT=CAAT||{};Function.prototype.bind=Function.prototype.bind||function(){var a=this,b=Array.prototype.slice.call(arguments),c=b.shift();return function(){return a.apply(c,b.concat(Array.prototype.slice.call(arguments)))}};CAAT.__CSS__=1;(function(){CAAT.BrowserDetect=function(){this.init();return this};CAAT.BrowserDetect.prototype={browser:"",version:0,OS:"",init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;b>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],m=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,l=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o>0,q=i+n*o>>0,r=j+l*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<< 24|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY:d.push([q,r,s,p]);break;case this.RampEnumeration.RAMP_CHANNEL_RGB_ARRAY:d.push([q,r,s])}}}return d}}})();(function(){CAAT.Color.RGB=function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this};CAAT.Color.RGB.prototype={r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}})();(function(){CAAT.Rectangle=function(){return this};CAAT.Rectangle.prototype={x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c, d);return this},contains:function(a,b){return a>=0&&a=0&&bthis.y1)this.y1=b;if(a>this.x1)this.x1=a;this.width=this.x1-this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1, -a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1this.x1?false:a.y1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1,a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= -0.5;for(var b=0;bthis.x1?false:a.y1this.y1?false:true},intersectsRect:function(a,b,c,d){return-1===c||-1===d?false:a+c-1this.x1?false:b+d-1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1, +a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= +0.5;for(var b=0;b=0&&ba*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y, a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}})();(function(){CAAT.QuadTree=function(){return this};CAAT.QuadTree.prototype={bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]=(new CAAT.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.QuadTree).create(h, b,c,i,this.bgActors);this.quadData[2]=(new CAAT.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e< +this.rows;e++){this.xycache.push([]);for(c=0;c=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status= -e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a&&a=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e=0;e=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}},calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return""; +CAAT.Behavior.Status.EXPIRED&&e.setExpired(a,b-this.behaviorStartTime)}return this},setFrameTime:function(a,b){CAAT.ContainerBehavior.superclass.setFrameTime.call(this,a,b);for(var c=this.behaviors,d=0;d=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}},calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return""; typeof c==="undefined"&&(c=100);for(var d=null,e="@-"+a+"-keyframes "+b+" {",f,b=0;b<=c;b++)f=this.interpolator.getPosition(b/c).y,d=this.calculateKeyFrameData(f,a,d),f=""+b/c*100+"%{"+d.rules+"}\n",d=d.ret,e+=f;e+="}";return e}};extend(CAAT.ContainerBehavior,CAAT.Behavior,null)})(); (function(){CAAT.RotateBehavior=function(){CAAT.RotateBehavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.RotateBehavior.prototype={startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);this.doValueApplication&&b.setRotationAnchored(c,this.anchorX,this.anchorY);return c},setValues:function(a,b,c,d){this.startAngle=a;this.endAngle= b;if(typeof c!=="undefined"&&typeof d!=="undefined")this.anchorX=c,this.anchorY=d;return this},setAngles:function(a,b){return this.setValues(a,b)},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"rotate("+(this.startAngle+a*(this.endAngle-this.startAngle))+"rad)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<= @@ -110,11 +115,10 @@ d,this.anchorX,this.anchorY);return{scaleX:c,scaleY:d}},setValues:function(a,b,c a*(this.endScaleY-this.startScaleY))+")"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.ScaleBehavior,CAAT.Behavior,null)})(); (function(){CAAT.AlphaBehavior=function(){CAAT.AlphaBehavior.superclass.constructor.call(this);return this};CAAT.AlphaBehavior.prototype={startAlpha:0,endAlpha:0,getPropertyName:function(){return"opacity"},setForTime:function(a,b){var c=this.startAlpha+a*(this.endAlpha-this.startAlpha);this.doValueApplication&&b.setAlpha(c);return c},setValues:function(a,b){this.startAlpha=a;this.endAlpha=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return this.startAlpha+ a*(this.endAlpha-this.startAlpha)},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}};extend(CAAT.AlphaBehavior,CAAT.Behavior,null)})(); -(function(){CAAT.PathBehavior=function(){CAAT.PathBehavior.superclass.constructor.call(this);return this};CAAT.PathBehavior.autorotate={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2};CAAT.PathBehavior.prototype={path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.PathBehavior.autorotate.FREE,translateX:0,translateY:0,getPropertyName:function(){return"translate"},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this}, -setValues:function(a){return this.setPath(a)},setTranslation:function(a,b){this.translateX=a;this.translateY=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+(a.x-this.translateX)+"px) translateY("+(a.y-this.translateY)+"px)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/ -c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.SpriteImage.prototype,h=CAAT.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE): -(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y}):{x:c.x-this.translateX,y:c.y-this.translateY}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a), -this.path.getPosition(a)):{x:-1,y:-1}}};extend(CAAT.PathBehavior,CAAT.Behavior)})();(function(){CAAT.ColorBehavior=function(){return this};CAAT.ColorBehavior.prototype={};extend(CAAT.ColorBehavior,CAAT.Behavior)})(); +(function(){CAAT.PathBehavior=function(){CAAT.PathBehavior.superclass.constructor.call(this);return this};CAAT.PathBehavior.autorotate={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2};CAAT.PathBehavior.prototype={path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.PathBehavior.autorotate.FREE,getPropertyName:function(){return"translate"},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(){return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+a.x+"px) translateY("+a.y+"px)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a); +if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.SpriteImage.prototype,h=CAAT.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL): +(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x,c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}};extend(CAAT.PathBehavior,CAAT.Behavior)})();(function(){CAAT.ColorBehavior=function(){return this};CAAT.ColorBehavior.prototype={};extend(CAAT.ColorBehavior,CAAT.Behavior)})(); (function(){CAAT.Scale1Behavior=function(){CAAT.Scale1Behavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.Scale1Behavior.prototype={startScale:1,endScale:1,anchorX:0.5,anchorY:0.5,sx:1,sy:1,applyOnX:true,getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScale+a*(this.endScale-this.startScale);0===c&&(c=0.01);this.doValueApplication&&(this.applyOnX?b.setScaleAnchored(c,b.scaleY,this.anchorX,this.anchorY):b.setScaleAnchored(b.scaleX, c,this.anchorX,this.anchorY));return c},setValues:function(a,b,c,d,e){this.startScale=a;this.endScale=b;this.applyOnX=!!c;if(typeof d!=="undefined"&&typeof e!=="undefined")this.anchorX=d,this.anchorY=e;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.startScale+a*(this.endScale-this.startScale);return this.applyOnX?"scaleX("+a+")":"scaleY("+a+")"},calculateKeyFramesData:function(a, b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.Scale1Behavior,CAAT.Behavior)})();(function(){CAAT.Debug=function(){return this};CAAT.Debug.prototype={width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'
CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0
Sound
Music
AA Bounding Boxes
Bounding Boxes
Dirty Rects
', @@ -124,11 +128,13 @@ document.getElementById("textEntitiesActive"),this.textDraws=document.getElement this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this.framerate.fpsMin,this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps),this.textFPS.innerHTML=this.framerate.fps,a=(this.frameTimeAcc*100/this.framerate.frames|0)/100,this.frameTimeAcc=0,this.textDrawTime.innerHTML=a,a=(this.frameRAFAcc*100/this.framerate.frames|0)/100,this.frameRAFAcc=0,this.textRAFTime.innerHTML=a,this.framerate.timeLastRefresh=CAAT.RAF,this.framerate.frames=0,this.paint(a);this.textEntitiesTotal.innerHTML= this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle="black";b.beginPath();b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>> 0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath();b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE* -this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}})();(function(){CAAT.Actor=function(){this.behaviorList=[];this.lifecycleListenerList=[];this.scaleAnchor=this.ANCHOR_CENTER;this.behaviorList=[];this.domElement=document.createElement("div");this.domElement.style.position="absolute";this.domElement.style["-webkit-transform"]="translate3d(0,0,0)";this.domElement.style["-webkit-transition"]="all 0s linear";this.style("display","none");this.setVisible(true);this.resetTransform();this.setScale(1,1);this.setRotation(0);this.modelViewMatrix=new CAAT.Matrix; -this.worldModelViewMatrix=new CAAT.Matrix;return this};CAAT.Actor.prototype={lifecycleListenerList:null,behaviorList:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,domParent:null,domElement:null,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5, -ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,mouseEnabled:true,time:0,inFrame:false,backgroundImage:null,size_active:1,size_total:1,id:null,__d_ax:-1,__d_ay:-1,gestureEnabled:false,setScreenBounds:function(){},setGestureEnabled:function(a){this.gestureEnabled=!!a},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent&&this.domParent.removeChild(this.domElement); -this.parent=a;null!=a?(this.parent.domElement.appendChild(this.domElement),this.domParent=this.parent.domElement):this.domParent=null;this.dirty=true;return this},setBackgroundImage:function(a,b){if(a){if(a instanceof HTMLImageElement)a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof HTMLCanvasElement)a.src=a.toDataURL(),a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof CAAT.SpriteImage){if(a.image instanceof HTMLCanvasElement&&!a.image.src)a.image.src=a.image.toDataURL()}else throw"Invalid image object to set actor's background"; -a.setOwner(this);this.backgroundImage=a;(typeof b==="undefined"||b)&&this.setSize(a.getWidth(),a.getHeight());this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())}else this.backgroundImage=null,this.style("background","none");return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())); +this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}})();(function(){CAAT.Actor=function(){this.behaviorList=[];this.lifecycleListenerList=[];this.scaleAnchor=this.ANCHOR_CENTER;this.behaviorList=[];this.domElement=document.createElement("div");this.domElement.style.position="absolute";this.domElement.style["-webkit-transform"]="translate3d(0,0,0)";this.domElement.style["-webkit-transition"]="all 0s linear";this.style("display","none");this.AABB=new CAAT.Rectangle;this.viewVertices=[new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0, +0,0)];this.setVisible(true);this.resetTransform();this.setScale(1,1);this.setRotation(0);this.modelViewMatrix=new CAAT.Matrix;this.worldModelViewMatrix=new CAAT.Matrix;return this};CAAT.Actor.prototype={lifecycleListenerList:null,behaviorList:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,tAnchorX:0,tAnchorY:0,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false, +domParent:null,domElement:null,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,mouseEnabled:true,time:0,inFrame:false,backgroundImage:null,size_active:1,size_total:1,id:null,__d_ax:-1,__d_ay:-1,gestureEnabled:false,AABB:null,viewVertices:null,isAA:true,setScreenBounds:function(){var a=this.AABB,b=this.viewVertices;if(this.isAA)return b=this.worldModelViewMatrix.matrix, +a.x=b[2],a.y=b[5],a.x1=b[2]+this.width,a.y1=b[5]+this.height,a.width=a.x1-a.x,a.height=a.y1-a.y,this;var c;c=b[0];c.x=0;c.y=0;c=b[1];c.x=this.width;c.y=0;c=b[2];c.x=this.width;c.y=this.height;c=b[3];c.x=0;c.y=this.height;this.modelToView(this.viewVertices);var d=Number.MAX_VALUE,e=-Number.MAX_VALUE,f=Number.MAX_VALUE,g=-Number.MAX_VALUE;c=b[0];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[1];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[2];if(c.x +e)e=c.x;if(c.yg)g=c.y;c=b[3];if(c.xe)e=c.x;if(c.yg)g=c.y;a.x=d;a.y=f;a.x1=e;a.y1=g;a.width=e-d;a.height=g-f;return this},setGestureEnabled:function(a){this.gestureEnabled=!!a},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent&&this.domParent.removeChild(this.domElement);this.parent=a;null!=a?(this.parent.domElement.appendChild(this.domElement), +this.domParent=this.parent.domElement):this.domParent=null;this.dirty=true;return this},setBackgroundImage:function(a,b){if(a){if(a instanceof HTMLImageElement)a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof HTMLCanvasElement)a.src=a.toDataURL(),a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof CAAT.SpriteImage){if(a.image instanceof HTMLCanvasElement&&!a.image.src)a.image.src=a.image.toDataURL()}else throw"Invalid image object to set actor's background";a.setOwner(this); +this.backgroundImage=a;(typeof b==="undefined"||b)&&this.setSize(a.getWidth(),a.getHeight());this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())}else this.backgroundImage=null,this.style("background","none");return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())); return this},setBackgroundImageOffset:function(a,b){this.backgroundImage&&(this.backgroundImage.setOffset(a,b),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setAnimationImageIndex:function(a){this.backgroundImage&&(this.backgroundImage.setAnimationImageIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setImageTransformation:function(a){this.transformation= a;a===CAAT.SpriteImage.prototype.TR_FIXED_TO_SIZE&&this.style("background-size","100%");return this},centerOn:function(a,b){this.setLocation(a-this.width/2,b-this.height/2);return this},centerAt:function(a,b){return this.centerOn(a,b)},setVisible:function(a){this.visible=a;return this},style:function(a,b){this.domElement.style[a]=b},style3:function(){var a="";this.transformation===CAAT.SpriteImage.prototype.TR_FLIP_HORIZONTAL&&(a=" scale(-1,1) ");a="translate("+this.x+"px,"+this.y+"px) rotate("+this.rotationAngle+ "rad) scale("+this.scaleX+","+this.scaleY+")"+a;this.domElement.style["-ms-transform"]=a;this.domElement.style["-webkit-transform"]="translate3d(0,0,0) "+a;this.domElement.style.OTransform=a;this.domElement.style.MozTransform=a;this.domElement.style.transform=a;a=""+this.rotationX*100+"% "+this.rotationY*100+"% ";this.domElement.style["transform-origin"]=a;this.domElement.style["-webkit-transform-origin"]=a;this.domElement.style["-ms-transform-origin"]=a;this.domElement.style.OTransformOrigin=a;this.domElement.style.MozTransformOrigin= @@ -136,20 +142,21 @@ a;return this},styleAlpha:function(){this.domElement.style.filter="alpha(opacity a){this.lifecycleListenerList.splice(b,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=a;return this},fireEvent:function(a,b){for(var c=0;c=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<= -a&&a=0&&b>=0&&a=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&b>=0&&ad+this.range?this.minSize:a===d?th this.ttask)this.ttask.cancel(),this.ttask=null},addChild:function(a){var b=this;a.__Dock_mouseEnter=a.mouseEnter;a.__Dock_mouseExit=a.mouseExit;a.__Dock_mouseMove=a.mouseMove;a.mouseEnter=function(a){b.actorMouseEnter(a);this.__Dock_mouseEnter(a)};a.mouseExit=function(a){b.actorMouseExit(a);this.__Dock_mouseExit(a)};a.mouseMove=function(a){b.actorPointed(a.point.x,a.point.y,a.source);this.__Dock_mouseMove(a)};a.width=this.minSize;a.height=this.minSize;return CAAT.Dock.superclass.addChild.call(this, a)}};extend(CAAT.Dock,CAAT.ActorContainer,null)})();(function(){CAAT.Director=function(){CAAT.Director.superclass.constructor.call(this);this.browserInfo=new CAAT.BrowserDetect;this.audioManager=(new CAAT.AudioManager).initialize(8);this.scenes=[];this.mousePoint=new CAAT.Point(0,0,0);this.prevMousePoint=new CAAT.Point(0,0,0);this.screenMousePoint=new CAAT.Point(0,0,0);this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Rectangle);this.dirtyRectsIndex= 0;return this};CAAT.Director.CLEAR_DIRTY_RECTS=1;CAAT.Director.CLEAR_ALL=true;CAAT.Director.CLEAR_NONE=false;CAAT.Director.prototype={debug:false,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false,lastSelectedActor:null,dragging:false,scenes:null,currentScene:null,canvas:null,crc:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:true,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null, -glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,size_dirtyRects:0,draws:0},currentTexturePage:0,currentOpacity:1,intervalId:null,frameCounter:0,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,nDirtyRects:0,collidingActors:null, -solveCollissions:function(){},addCollidingActor:function(a){this.collidingActors.push(a)},checkDebug:function(){if(CAAT.DEBUG){var a=(new CAAT.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){switch(this.resize){case this.RESIZE_WIDTH:this.setBounds(0,0,a,this.height);break;case this.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case this.RESIZE_BOTH:this.setBounds(0,0,a,b);break; -case this.RESIZE_PROPORTIONAL:this.setScaleProportional(a,b)}this.glEnabled&&this.glReset();if(this.onResizeCallback)this.onResizeCallback(this,a,b)},setScaleProportional:function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");this.glEnabled&&this.glReset()},enableResizeEvents:function(a, -b){a===this.RESIZE_BOTH||a===this.RESIZE_WIDTH||a===this.RESIZE_HEIGHT||a===this.RESIZE_PROPORTIONAL?(this.referenceWidth=this.width,this.referenceHeight=this.height,this.resize=a,CAAT.registerResizeListener(this),this.onResizeCallback=b,this.windowResized(window.innerWidth,window.innerHeight)):(CAAT.unregisterResizeListener(this),this.onResizeCallback=null)},setBounds:function(a,b,c,d){CAAT.Director.superclass.setBounds.call(this,a,b,c,d);this.canvas.width=c;this.canvas.height=d;this.crc=this.ctx= -this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");for(a=0;a=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total= -0;this.statistics.size_active=0;this.statistics.draws=0},render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0}, +render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0)f.clip(),f.fillStyle="rgba(160,255,150,.4)",f.fillRect(0,0,this.width,this.height)}f.restore()}this.frameCounter++},animate:function(){this.setModelViewMatrix(this);this.setScreenBounds(); -this.invalid=this.dirty=false;this.dirtyRectsIndex=-1;this.cDirtyRects=[];this.collidingActors=[];for(var a=this.childrenList,b,c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width, -this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;a.restore();this.ctx=c;this.crc=d}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&& -this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene;a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform();a.setLocation(0, -0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e<0.33?(e=CAAT.Scene.prototype.EASE_ROTATION, -g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE, -h=(new CAAT.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)},setScene:function(a){a=this.scenes[a]; -this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)},switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene); -this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled= -true;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"):null,/^(fixed)$/.test(g))break;else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset"); -return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI= -this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x, -this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x, -b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x= -c.x;this.prevMousePoint.y=c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, -this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y, -a,b,this.screenMousePoint,this.currentScene.time)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time);this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_= -this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y, -0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)}, -__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0, +0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;a.restore();this.ctx=c;this.crc=d}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null=== +this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene;a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform(); +a.setLocation(0,0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e< +0.33?(e=CAAT.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)): +(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)}, +setScene:function(a){a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)},switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a, +b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b)}, +endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled=true;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"):null,/^(fixed)$/.test(g))break; +else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset");return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+ +document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c= +b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a), +c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0));this.dragging=true;var e=b.x,f=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),d));this.prevMousePoint.x=c.x;this.prevMousePoint.y=c.y;if(e===b.x&&f===b.y){e=b.contains(c.x,c.y);if(this.in_&&!e)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=false;if(!this.in_&&e)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=true}}else this.in_= +true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,d))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint, +d)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time); +this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_=this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScane?this.currentScene.time: +0),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor, +this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b>0)*e;var k=i+(d/h>>0)*f,m=g+e,n=k+f;g=(new CAAT.SpriteImageHelper(g,k,m-g,n-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,n/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(g-=e);var h=this.offsetY%f;h>0&&(h-=f);var e=((this.ownerActor.width-g)/e>>0)+1,f=((this.ownerActor.height-h)/f>>0)+1,i,j;for(i=0;i>0,d+h+i* -b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width, -b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image, -b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return"-"+(a.x-this.offsetX)+"px -"+(a.y-this.offsetY)+"px "+(this.transformation===this.TR_TILE? -"":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]= -g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;switch(a){case this.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case this.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case this.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case this.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case this.TR_TILE:this.paint=this.paintTiled;break; -default:this.paint=this.paintN}return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1)this.prevAnimationTime===-1?(this.prevAnimationTime=a,this.spriteIndex=0):(a-=this.prevAnimationTime,a/=this.changeFPS,a%=this.animationImageIndex.length,this.spriteIndex=this.animationImageIndex[Math.floor(a)])},getMapInfo:function(a){return this.mapInfo[a]}, -initializeFromMap:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b)d=b[c],d=new CAAT.SpriteImageHelper(d.x,d.y,d.width,d.height,a.width,a.height),this.mapInfo[c]=d,e||this.setAnimationImageIndex([c]),e++;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.SpriteImageHelper(f.x,f.y,f.width,f.height,a.width,a.height);d.xoffset=typeof f.xoffset==="undefined"?0:f.xoffset;d.yoffset=typeof f.yoffset==="undefined"?0:f.yoffset; -d.xadvance=typeof f.xadvance==="undefined"?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>0,f=0;f=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)):this.callback_tick&&this.callback_tick(a, +g=new CAAT.SpriteImageHelper(e,f,this.singleWidth,this.singleHeight,a.width,a.height),this.mapInfo[d]=g;return this},paintTiled:function(a,b){this.setSpriteIndexAtTime(b);var c=this.mapInfo[this.spriteIndex],d=new CAAT.Rectangle;this.ownerActor.AABB.intersect(a.AABB,d);var e=this.getWidth(),f=this.getHeight(),g=(this.offsetX-this.ownerActor.x)%e;g>0&&(g-=e);var h=(this.offsetY-this.ownerActor.y)%f;h>0&&(h-=f);var e=((d.width-g)/e>>0)+1,f=((d.height-h)/f>>0)+1,i,j,k=a.ctx;for(i=0;i>0,d.y-this.ownerActor.y+h+i*c.height>>0,c.width,c.height)},paintInvertedH:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex]; +a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this}, +paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex]; +return"-"+(a.x-this.offsetX)+"px -"+(a.y-this.offsetY)+"px "+(this.transformation===this.TR_TILE?"":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v, +h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;switch(a){case this.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case this.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case this.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case this.TR_FIXED_TO_SIZE:this.paint= +this.paintScaled;break;case this.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1)this.prevAnimationTime===-1?(this.prevAnimationTime=a,this.spriteIndex=0):(a-=this.prevAnimationTime,a/=this.changeFPS,a%=this.animationImageIndex.length,this.spriteIndex= +this.animationImageIndex[Math.floor(a)])},getMapInfo:function(a){return this.mapInfo[a]},initializeFromMap:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b)d=b[c],d=new CAAT.SpriteImageHelper(d.x,d.y,d.width,d.height,a.width,a.height),this.mapInfo[c]=d,e||this.setAnimationImageIndex([c]),e++;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.SpriteImageHelper(f.x,f.y,f.width,f.height,a.width,a.height);d.xoffset=typeof f.xoffset=== +"undefined"?0:f.xoffset;d.yoffset=typeof f.yoffset==="undefined"?0:f.yoffset;d.xadvance=typeof f.xadvance==="undefined"?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>0,f=0;fa&&(a=c)}return this.fontHeight=a},drawString:function(a,b,c,d){for(var e, +f,g=b.split(""),b=0;b=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)):this.callback_tick&&this.callback_tick(a, b,this);return this},reset:function(a){this.remove=false;this.startTime=a;this.scene.ensureTimerTask(this);return this},cancel:function(){this.remove=true;null!=this.callback_cancel&&this.callback_cancel(this.scene.time,this.scene.time-this.startTime,this);return this}}})();(function(){CAAT.Scene=function(){CAAT.Scene.superclass.constructor.call(this);this.timerList=[];this.style("overflow","hidden");return this};CAAT.Scene.prototype={easeContainerBehaviour:null,easeContainerBehaviourListener:null,easeIn:false,EASE_ROTATION:1,EASE_SCALE:2,EASE_TRANSLATE:3,timerList:null,timerSequence:0,paused:false,isPaused:function(){return this.paused},setPaused:function(a){this.paused=a},checkTimers:function(a){for(var b=this.timerList.length-1;b>=0;)this.timerList[b].remove||this.timerList[b].checkTask(a), b--},ensureTimerTask:function(a){this.hasTimer(a)||this.timerList.push(a);return this},hasTimer:function(a){for(var b=this.timerList.length-1;b>=0;){if(this.timerList[b]===a)return true;b--}return false},createTimer:function(a,b,c,d,e){a=(new CAAT.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=this.time;a.scene=this;this.timerList.push(a);return a},removeExpiredTimers:function(){var a;for(a=0;a>0)+1)+2*b,f.push(h),e+=h;c.width=e;c.height=this.fontSize*1.5>>0;d=c.getContext("2d"); d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.crc;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x, -this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),c.arc(this.points[0].x,this.points[0].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.arc(this.points[1].x,this.points[1].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill();c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0];else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone()); +startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color; +c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0];else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone()); return a}};extend(CAAT.LinearPath,CAAT.PathSegment)})(); (function(){CAAT.CurvePath=function(){CAAT.CurvePath.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.CurvePath.prototype={curve:null,newPosition:null,applyAsPath:function(a){this.curve.applyAsPath(a);return this},setPoint:function(a,b){this.curve&&this.curve.setPoint(a,b)},setPoints:function(a){var b=new CAAT.Bezier;b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.Bezier;g.setQuadric(a,b,c,d,e,f);this.curve=g;this.updatePath(); return this},setCubic:function(a,b,c,d,e,f,g,h){var i=new CAAT.Bezier;i.setCubic(a,b,c,d,e,f,g,h);this.curve=i;this.updatePath();return this},updatePath:function(){this.curve.update();this.length=this.curve.getLength();this.curve.getBoundingBox(this.bbox);return this},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition,a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x}, -finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]},endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/ +finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]},endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/ a,y:this.getPosition(c/a).y});return b}};extend(CAAT.CurvePath,CAAT.PathSegment,null)})(); (function(){CAAT.ShapePath=function(){CAAT.ShapePath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point;return this};CAAT.ShapePath.prototype={points:null,length:-1,cw:true,bbox:null,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x, this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x,this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1;a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c, -b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;f1||a<0)a%=1;a<0&&(a=1+a);for(var b=false,c=0;c0?this.pathSegmentStartTime[b]=this.pathSegmentStartTime[b-1]+this.pathSegmentDurationTime[b-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[b].endPath();this.extractPathPoints();return this},press:function(a,b){if(this.interactive){for(var c= -CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b1||a<0)a%=1;a<0&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,i;e!==f;)if(g=(f+e)/2|0,i=c[g],i<=a&&a<=i+d[g])return a=d[g]?(a-i)/d[g]:0,a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;else a0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();typeof b!=="undefined"&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b this.x1 ) { + return false; + } + if ( y1< this.y ) { + return false; + } + if ( y> this.y1 ) { + return false; + } + + return true; + }, + intersect : function( i, r ) { if ( typeof r==='undefined' ) { r= new CAAT.Rectangle(); @@ -1704,10 +1729,14 @@ var cp1= proxy( ctx.lineTo( this.coordlist[3].x, this.coordlist[3].y ); ctx.stroke(); } - + + ctx.globalAlpha=0.5; for( var i=0; i - * Incomplete class, do not use. + * This object manages one single catmull rom segment, that is 4 points. + * A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points. * * @constructor * @extends CAAT.Curve @@ -2096,26 +2127,19 @@ var cp1= proxy( /** * Set curve control points. - * @param cp0x {number} - * @param cp0y {number} - * @param cp1x {number} - * @param cp1y {number} - * @param cp2x {number} - * @param cp2y {number} - * @param cp3x {number} - * @param cp3y {number} + * @param points Array */ - setCurve : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) { - + setCurve : function( p0, p1, p2, p3 ) { + this.coordlist= []; - - this.coordlist.push( new CAAT.Point().set(cp0x, cp0y ) ); - this.coordlist.push( new CAAT.Point().set(cp1x, cp1y ) ); - this.coordlist.push( new CAAT.Point().set(cp2x, cp2y ) ); - this.coordlist.push( new CAAT.Point().set(cp3x, cp3y ) ); - - this.cubic= true; + this.coordlist.push( p0 ); + this.coordlist.push( p1 ); + this.coordlist.push( p2 ); + this.coordlist.push( p3 ); + this.update(); + + return this; }, /** * Paint the contour by solving again the entire curve. @@ -2123,9 +2147,12 @@ var cp1= proxy( */ paint: function(director) { - var x1,x2,y1,y2; - x1 = this.coordlist[0].x; - y1 = this.coordlist[0].y; + var x1,y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; var ctx= director.ctx; @@ -2134,7 +2161,7 @@ var cp1= proxy( ctx.moveTo(x1,y1); var point= new CAAT.Point(); - + for(var t=this.k;t<=1+this.k;t+=this.k){ this.solve(point,t); ctx.lineTo(point.x,point.y); @@ -2151,19 +2178,17 @@ var cp1= proxy( * @param t {number} a number in the range 0..1 */ solve: function(point,t) { - var t2= t*t; - var t3= t*t2; - var c= this.coordlist; -// q(t) = 0.5 *( (2 * P1) + -// (-P0 + P2) * t + -// (2*P0 - 5*P1 + 4*P2 - P3) * t2 + -// (-P0 + 3*P1- 3*P2 + P3) * t3) + // Handy from CAKE. Thanks. + var af = ((-t+2)*t-1)*t*0.5 + var bf = (((3*t-5)*t)*t+2)*0.5 + var cf = ((-3*t+4)*t+1)*t*0.5 + var df = ((t-1)*t*t)*0.5 + + point.x= c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y= c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; - point.x= 0.5*( (2*c[1].x) + (-c[0].x+c[2].x)*t + (2*c[0].x - 5*c[1].x + 4*c[2].x - c[3].x)*t2 + (-c[0].x + 3*c[1].x - 3*c[2].x + c[3].x)*t3 ); - point.y= 0.5*( (2*c[1].y) + (-c[0].y+c[2].y)*t + (2*c[0].y - 5*c[1].y + 4*c[2].y - c[3].y)*t2 + (-c[0].y + 3*c[1].y - 3*c[2].y + c[3].y)*t3 ); - return point; } @@ -2486,6 +2511,178 @@ var cp1= proxy( }; extend( CAAT.QuadTree, CAAT.Rectangle ); +})(); + +(function() { + + CAAT.SpatialHash= function() { + return this; + }; + + CAAT.SpatialHash.prototype= { + + elements : null, + + width : null, + height : null, + + rows : null, + columns : null, + + xcache : null, + ycache : null, + xycache : null, + + rectangle : null, + r0 : null, + r1 : null, + + initialize : function( w,h, rows,columns ) { + + var i, j; + + this.elements= []; + for( i=0; i>0 ); + } + + this.ycache= []; + for( i=0; i>0 ); + } + + this.xycache=[]; + for( i=0; isetTranslation(actor.width/2, actor.height/2);. - * - * Displacement will be substracted from the tarrget coordinate. - * + * @see Acotr.setPositionAcchor + * @deprecated * @param tx a float with xoffset. * @param ty a float with yoffset. */ setTranslation : function( tx, ty ) { - this.translateX= tx; - this.translateY= ty; return this; }, calculateKeyFrameData : function( time ) { time= this.interpolator.getPosition(time).y; var point= this.path.getPosition(time); - return "translateX("+(point.x-this.translateX)+"px) translateY("+(point.y-this.translateY)+"px)" ; + return "translateX("+point.x+"px) translateY("+point.y+"px)" ; }, calculateKeyFramesData : function(prefix, name, keyframessize) { @@ -4208,7 +4422,7 @@ var cp1= proxy( var ay= point.y-this.prevY; if ( ax===0 && ay===0 ) { - actor.setLocation( point.x-this.translateX, point.y-this.translateY ); + actor.setLocation( point.x, point.y ); return { x: actor.x, y: actor.y }; } @@ -4246,12 +4460,12 @@ var cp1= proxy( } if ( this.doValueApplication ) { - actor.setLocation( point.x-this.translateX, point.y-this.translateY ); + actor.setLocation( point.x, point.y ); return { x: actor.x, y: actor.y }; } else { return { - x: point.x-this.translateX, - y: point.y-this.translateY + x: point.x, + y: point.y }; } @@ -5183,6 +5397,14 @@ var cp1= proxy( this.domElement.style['-webkit-transition']='all 0s linear'; this.style( 'display', 'none'); + this.AABB= new CAAT.Rectangle(); + this.viewVertices= [ + new CAAT.Point(0,0,0), + new CAAT.Point(0,0,0), + new CAAT.Point(0,0,0), + new CAAT.Point(0,0,0) + ]; + this.setVisible(true); this.resetTransform(); this.setScale(1,1); @@ -5206,6 +5428,8 @@ var cp1= proxy( duration: Number.MAX_VALUE, // Actor duration in Scene time clip: false, // should clip the Actor's content against its contour. + tAnchorX : 0, + tAnchorY : 0, scaleX: 0, // transformation. width scale parameter scaleY: 0, // transformation. height scale parameter scaleTX: .50, // transformation. scale anchor x position @@ -5251,8 +5475,116 @@ var cp1= proxy( __d_ay: -1, gestureEnabled: false, - setScreenBounds : function() { + AABB : null, + viewVertices: null, // model to view transformed vertices. + isAA : true, + /** + * Calculates the 2D bounding box in canvas coordinates of the Actor. + * This bounding box takes into account the transformations applied hierarchically for + * each Scene Actor. + * + * @private + * + */ + setScreenBounds : function() { + + var AABB= this.AABB; + var vv= this.viewVertices; + + if ( this.isAA ) { + var m= this.worldModelViewMatrix.matrix; + AABB.x= m[2]; + AABB.y= m[5]; + AABB.x1= m[2] + this.width; + AABB.y1= m[5] + this.height; + AABB.width= AABB.x1-AABB.x; + AABB.height= AABB.y1-AABB.y; + return this; + } + + + var vvv; + + vvv= vv[0]; + vvv.x=0; + vvv.y=0; + vvv= vv[1]; + vvv.x=this.width; + vvv.y=0; + vvv= vv[2]; + vvv.x=this.width; + vvv.y=this.height; + vvv= vv[3]; + vvv.x=0; + vvv.y=this.height; + + this.modelToView( this.viewVertices ); + + var xmin= Number.MAX_VALUE, xmax=-Number.MAX_VALUE; + var ymin= Number.MAX_VALUE, ymax=-Number.MAX_VALUE; + + vvv= vv[0]; + if ( vvv.x < xmin ) { + xmin=vvv.x; + } + if ( vvv.x > xmax ) { + xmax=vvv.x; + } + if ( vvv.y < ymin ) { + ymin=vvv.y; + } + if ( vvv.y > ymax ) { + ymax=vvv.y; + } + var vvv= vv[1]; + if ( vvv.x < xmin ) { + xmin=vvv.x; + } + if ( vvv.x > xmax ) { + xmax=vvv.x; + } + if ( vvv.y < ymin ) { + ymin=vvv.y; + } + if ( vvv.y > ymax ) { + ymax=vvv.y; + } + var vvv= vv[2]; + if ( vvv.x < xmin ) { + xmin=vvv.x; + } + if ( vvv.x > xmax ) { + xmax=vvv.x; + } + if ( vvv.y < ymin ) { + ymin=vvv.y; + } + if ( vvv.y > ymax ) { + ymax=vvv.y; + } + var vvv= vv[3]; + if ( vvv.x < xmin ) { + xmin=vvv.x; + } + if ( vvv.x > xmax ) { + xmax=vvv.x; + } + if ( vvv.y < ymin ) { + ymin=vvv.y; + } + if ( vvv.y > ymax ) { + ymax=vvv.y; + } + + AABB.x= xmin; + AABB.y= ymin; + AABB.x1= xmax; + AABB.y1= ymax; + AABB.width= (xmax-xmin); + AABB.height= (ymax-ymin); + + return this; }, setGestureEnabled : function( enable ) { this.gestureEnabled= !!enable; @@ -5738,21 +6070,46 @@ var cp1= proxy( return { x: anchors[anchor*2], y: anchors[anchor*2+1] }; }, + + setGlobalAnchor : function( ax, ay ) { + this.tAnchorX= ax; + this.rotationX= ax; + this.scaleTX= ax; + + this.tAnchorY= ay; + this.rotationY= ay; + this.scaleTY= ay; + + this.dirty= true; + return this; + }, + + setScaleAnchor : function( sax, say ) { + this.rotationX= sax; + this.rotationY= say; + this.scaleTX= sax; + this.scaleTY= say; + + this.style3(); + + this.dirty= true; + return this; + }, /** * Modify the dimensions on an Actor. * The dimension will not affect the local coordinates system in opposition * to setSize or setBounds. * - * @param sx a float indicating a width size multiplier. - * @param sy a float indicating a height size multiplier. - * @param anchor an integer indicating the anchor to perform the Scale operation. + * @param sx {number} width scale. + * @param sy {number} height scale. + * @param anchorx {number} x anchor to perform the Scale operation. + * @param anchory {number} y anchor to perform the Scale operation. * * @return this; */ setScaleAnchored : function( sx, sy, anchorx, anchory ) { - - this.rotationX= anchorx; - this.rotationY= anchory; + this.rotationX= anchorx; + this.rotationY= anchory; this.scaleTX= anchorx; this.scaleTY= anchory; @@ -5765,6 +6122,9 @@ var cp1= proxy( return this; }, + + + /** * A helper method for setRotationAnchored. This methods stablishes the center * of rotation to be the center of the Actor. @@ -5773,27 +6133,30 @@ var cp1= proxy( * @return this */ setRotation : function( angle ) { - this.setRotationAnchored( angle, .5, .5 ); + this.rotationAngle= angle; + this.style3( ); + this.dirty= true; return this; }, - /** - * This method sets Actor rotation around a given position. - * @param angle a float indicating the angle in radians to rotate the Actor. - * @param rx - * @param ry - * @return this; - */ - setRotationAnchored : function( angle, rx, ry ) { - this.rotationAngle= angle; - this.rotationX= rx?rx:0; - this.rotationY= ry?ry:0; + setRotationAnchor : function( rax, ray ) { + this.rotationX= ray; + this.rotationY= rax; this.style3( ); - this.dirty= true; + return this; + }, + + setRotationAnchored : function( angle, rx, ry ) { + this.rotationAngle= angle; + this.rotationX= rx; + this.rotationY= ry; + this.style3( ); + this.dirty= true; return this; - }, + }, + /** * Sets an Actor's dimension * @param w a float indicating Actor's width. @@ -5836,6 +6199,29 @@ var cp1= proxy( return this; }, + + + setPosition : function( x,y ) { + return this.setLocation( x,y ); + }, + + setPositionAnchor : function( pax, pay ) { + this.tAnchorX= pax; + this.tAnchorY= pay; + this.style3(); + this.dirty= true; + return this; + }, + + setPositionAnchored : function( x,y,pax,pay ) { + this.setLocation( x,y ); + this.tAnchorX= pax; + this.tAnchorY= pay; + return this; + }, + + + /** * This method sets the position of an Actor inside its parent. * @@ -6326,15 +6712,21 @@ var cp1= proxy( this.setModelViewMatrix(false); + if ( this.dirty || this.wdirty || this.invalid ) { + this.setScreenBounds(); + } + this.dirty= false; - return true; + //return true; + return this.AABB.intersects( director.AABB ); }, /** * Set this model view matrix if the actor is Dirty. * * @return this */ + /* setModelViewMatrix : function(glEnabled) { var c,s,_m00,_m01,_m10,_m11; var mm0, mm1, mm2, mm3, mm4, mm5; @@ -6414,7 +6806,103 @@ var cp1= proxy( return this; + },*/ + + setModelViewMatrix : function() { + var c,s,_m00,_m01,_m10,_m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty= false; + mm= this.modelViewMatrix.matrix; + + if ( this.dirty ) { + + mm0= 1; + mm1= 0; + //mm2= mm[2]; + mm3= 0; + mm4= 1; + //mm5= mm[5]; + + mm2= this.x - this.tAnchorX * this.width ; + mm5= this.y - this.tAnchorY * this.height; + + if ( this.rotationAngle ) { + + var rx= this.rotationX*this.width; + var ry= this.rotationY*this.height; + + mm2+= mm0*rx + mm1*ry; + mm5+= mm3*rx + mm4*ry; + + c= Math.cos( this.rotationAngle ); + s= Math.sin( this.rotationAngle ); + _m00= mm0; + _m01= mm1; + _m10= mm3; + _m11= mm4; + mm0= _m00*c + _m01*s; + mm1= -_m00*s + _m01*c; + mm3= _m10*c + _m11*s; + mm4= -_m10*s + _m11*c; + + mm2+= -mm0*rx - mm1*ry; + mm5+= -mm3*rx - mm4*ry; + } + if ( this.scaleX!=1 || this.scaleY!=1 ) { + + var sx= this.scaleTX*this.width; + var sy= this.scaleTY*this.height; + + mm2+= mm0*sx + mm1*sy; + mm5+= mm3*sx + mm4*sy; + + mm0= mm0*this.scaleX; + mm1= mm1*this.scaleY; + mm3= mm3*this.scaleX; + mm4= mm4*this.scaleY; + + mm2+= -mm0*sx - mm1*sy; + mm5+= -mm3*sx - mm4*sy; + } + + mm[0]= mm0; + mm[1]= mm1; + mm[2]= mm2; + mm[3]= mm3; + mm[4]= mm4; + mm[5]= mm5; + } + + if ( this.parent ) { + + + this.isAA= this.rotationAngle===0 && this.scaleX===1 && this.scaleY===1 && this.parent.isAA; + + if ( this.dirty || this.parent.wdirty ) { + this.worldModelViewMatrix.copy( this.parent.worldModelViewMatrix ); + if ( this.isAA ) { + var mmm= this.worldModelViewMatrix.matrix; + mmm[2]+= mm[2]; + mmm[5]+= mm[5]; + } else { + this.worldModelViewMatrix.multiply( this.modelViewMatrix ); + } + this.wdirty= true; + } + + } else { + if ( this.dirty ) { + this.wdirty= true; + } + + this.worldModelViewMatrix.identity(); + this.isAA= this.rotationAngle===0 && this.scaleX===1 && this.scaleY===1; + } + }, + /** * @private. * This method will be called by the Director to set the whole Actor pre-render process. @@ -7821,18 +8309,6 @@ var cp1= proxy( dirtyRectsEnabled : false, nDirtyRects : 0, - collidingActors : null, - - solveCollissions : function() { - if ( !this.collidingActors.length ) { - return; - } - - - }, - addCollidingActor : function( actor ) { - this.collidingActors.push( actor ); - }, checkDebug : function() { if ( CAAT.DEBUG ) { var dd= new CAAT.Debug().initialize( this.width, 60 ); @@ -7949,7 +8425,10 @@ var cp1= proxy( * @return this */ initialize : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } this.canvas = canvas; if ( typeof proxy==='undefined' ) { @@ -7993,7 +8472,11 @@ var cp1= proxy( */ initializeGL : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } + canvas.width = width; canvas.height = height; @@ -8010,6 +8493,7 @@ var cp1= proxy( this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); this.gl.viewportWidth = width; this.gl.viewportHeight = height; + CAAT.GLRENDER= true; } catch(e) { } @@ -8288,6 +8772,8 @@ var cp1= proxy( ctx.save(); if ( this.dirtyRectsEnabled ) { + this.modelViewMatrix.transformRenderingContext( ctx ); + if ( !CAAT.DEBUG_DIRTYRECTS ) { ctx.beginPath(); this.nDirtyRects=0; @@ -8353,7 +8839,7 @@ var cp1= proxy( } } - if ( CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { + if ( this.nDirtyRects>0 && CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { ctx.beginPath(); this.nDirtyRects=0; var dr= this.cDirtyRects; @@ -8364,11 +8850,10 @@ var cp1= proxy( this.nDirtyRects++; } } - if ( this.nDirtyRects>0 ) { - ctx.clip(); - ctx.fillStyle='rgba(160,255,150,.4)'; - ctx.fillRect(0,0,this.width, this.height); - } + + ctx.clip(); + ctx.fillStyle='rgba(160,255,150,.4)'; + ctx.fillRect(0,0,this.width, this.height); } ctx.restore(); @@ -8386,13 +8871,13 @@ var cp1= proxy( */ animate : function(director, time) { this.setModelViewMatrix(this); + this.modelViewMatrixI= this.modelViewMatrix.getInverse(); this.setScreenBounds(); this.dirty= false; this.invalid= false; this.dirtyRectsIndex= -1; this.cDirtyRects= []; - this.collidingActors= []; var cl= this.childrenList; var cli; @@ -8402,8 +8887,6 @@ var cp1= proxy( cli.animate(this, tt); } - this.solveCollissions(); - return this; }, /** @@ -9187,7 +9670,9 @@ var cp1= proxy( // transformar coordenada inversamente con affine transform de director. var pt= new CAAT.Point( posx, posy ); - this.modelViewMatrixI= this.modelViewMatrix.getInverse(); + if ( !this.modelViewMatrixI ) { + this.modelViewMatrixI= this.modelViewMatrix.getInverse(); + } this.modelViewMatrixI.transformCoord(pt); posx= pt.x; posy= pt.y @@ -9280,6 +9765,8 @@ var cp1= proxy( var lactor; var pos; + var ct= this.currentScene ? this.currentScene.time : 0; + // drag if (this.isMouseDown && null !== this.lastSelectedActor) { @@ -9311,7 +9798,7 @@ var cp1= proxy( new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y), - this.currentScene.time)); + ct)); this.prevMousePoint.x= pos.x; this.prevMousePoint.y= pos.y; @@ -9331,7 +9818,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = false; } @@ -9343,7 +9830,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = true; } } @@ -9370,7 +9857,7 @@ var cp1= proxy( e, this.lastSelectedActor, this.screenMousePoint, - this.currentScene.time)); + ct)); } if (null !== lactor) { @@ -9384,7 +9871,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } } @@ -9400,7 +9887,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } this.lastSelectedActor = lactor; @@ -9455,7 +9942,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time); + this.currentScane ? this.currentScene.time : 0); lactor.mouseOver(ev); lactor.mouseEnter(ev); @@ -9767,7 +10254,8 @@ var cp1= proxy( } extend(CAAT.Director, CAAT.ActorContainer, null); -})();/** +})(); +/** * See LICENSE file. * * MouseEvent is a class to hold necessary information of every mouse event related to concrete @@ -9853,6 +10341,8 @@ CAAT.setCoordinateClamping= function( clamp ) { */ CAAT.PMR= 64; +CAAT.GLRENDER= false; + /** * Allow visual debugging artifacts. */ @@ -10562,29 +11052,32 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { this.setSpriteIndexAtTime(time); var el= this.mapInfo[this.spriteIndex]; + var r= new CAAT.Rectangle(); + this.ownerActor.AABB.intersect( director.AABB, r ); + var w= this.getWidth(); var h= this.getHeight(); - var xoff= this.offsetX % w; + var xoff= (this.offsetX-this.ownerActor.x) % w; if ( xoff> 0 ) { xoff= xoff-w; } - var yoff= this.offsetY % h; + var yoff= (this.offsetY-this.ownerActor.y) % h; if ( yoff> 0 ) { yoff= yoff-h; } - var nw= (((this.ownerActor.width-xoff)/w)>>0)+1; - var nh= (((this.ownerActor.height-yoff)/h)>>0)+1; + var nw= (((r.width-xoff)/w)>>0)+1; + var nh= (((r.height-yoff)/h)>>0)+1; var i,j; var ctx= director.ctx; for( i=0; i>0, (y+yoff+i*el.height)>>0, + (r.x-this.ownerActor.x+xoff+j*el.width)>>0, (r.y-this.ownerActor.y+yoff+i*el.height)>>0, el.width, el.height); } } @@ -11071,6 +11564,25 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { return w; }, + stringHeight : function() { + if ( this.fontHeight ) { + return this.fontHeight; + } + + var y= 0; + for( var i in this.mapInfo ) { + var mi= this.mapInfo[i]; + + var h= mi.height+mi.yoffset; + if ( h>y ) { + y=h; + } + } + + this.fontHeight= y; + return this.fontHeight; + }, + drawString : function( ctx, str, x, y ) { var i, l, charInfo, w; var charArr = str.split(""); @@ -12945,7 +13457,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** }; CAAT.PathSegment.prototype = { - color: 'black', + color: '#000', length: 0, bbox: null, parent: null, @@ -13063,7 +13575,21 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Transform this path with the given affinetransform matrix. * @param matrix */ - transform : function(matrix) {} + transform : function(matrix) {}, + + drawHandle : function( ctx, x, y ) { + var w= CAAT.Curve.prototype.HANDLE_SIZE/2; + ctx.fillRect( x-w, y-w, w*2, w*2 ); + /* + ctx.arc( + this.points[0].x, + this.points[0].y, + CAAT.Curve.prototype.HANDLE_SIZE/2, + 0, + 2*Math.PI, + false) ; + */ + } }; })(); @@ -13172,6 +13698,9 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this.newPosition; }, + getPositionFromLength : function( len ) { + return this.getPosition( len/this.length ); + }, /** * Returns initial path segment point's x coordinate. * @return {number} @@ -13194,20 +13723,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.moveTo( this.points[0].x, this.points[0].y ); - canvas.lineTo( this.points[1].x, this.points[1].y ); - canvas.stroke(); + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.moveTo( this.points[0].x, this.points[0].y ); + ctx.lineTo( this.points[1].x, this.points[1].y ); + ctx.stroke(); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; - canvas.beginPath(); + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; + ctx.beginPath(); + this.drawHandle( ctx, this.points[0].x, this.points[0].y ); + this.drawHandle( ctx, this.points[1].x, this.points[1].y ); + /* canvas.arc( this.points[0].x, this.points[0].y, @@ -13223,9 +13755,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** 2*Math.PI, false) ; canvas.fill(); + */ } - canvas.restore(); + ctx.restore(); }, /** * Get the number of control points. For this type of path segment, start and @@ -13395,7 +13928,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** paint : function( director,bDrawHandles ) { this.curve.drawHandles= bDrawHandles; director.ctx.strokeStyle= this.color; - this.curve.paint(director); + this.curve.paint(director,bDrawHandles); }, /** * @inheritDoc @@ -13628,21 +14161,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.strokeRect( + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.strokeRect( this.bbox.x, this.bbox.y, this.bbox.width, this.bbox.height ); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; for( var i=0; i=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + }, /** * Analogously to the method getPosition, this method returns a CAAT.Point instance with @@ -14288,7 +14879,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Indicates that some path control point has changed, and that the path must recalculate * its internal data, ie: length and bbox. */ - updatePath : function(point) { + updatePath : function(point, callback) { var i,j; this.length=0; @@ -14346,6 +14937,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.extractPathPoints(); + if ( typeof callback!=='undefined' ) { + callback(this); + } + return this; }, @@ -14382,7 +14977,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * @param x {number} * @param y {number} */ - drag : function(x,y) { + drag : function(x,y,callback) { if (!this.interactive) { return; } @@ -14402,7 +14997,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.ax= x; this.ay= y; - this.updatePath(this.point); + this.updatePath(this.point,callback); }, /** * Returns a collection of CAAT.Point objects which conform a path's contour. @@ -14554,8 +15149,8 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** mm3= 0; mm4= 1; - mm2= this.tb_x - bbx; - mm5= this.tb_y - bby; + mm2= this.tb_x - bbx - this.tAnchorX * bbw; + mm5= this.tb_y - bby - this.tAnchorY * bbh; if ( this.rb_angle ) { @@ -14615,6 +15210,15 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this; }, + setRotationAnchor : function( ax, ay ) { + this.rb_rotateAnchorX= ax; + this.rb_rotateAnchorY= ay; + }, + + setRotation : function( angle ) { + this.rb_angle= angle; + }, + setScaleAnchored : function( scaleX, scaleY, sx, sy ) { this.sb_scaleX= scaleX; this.sb_scaleAnchorX= sx; @@ -14623,10 +15227,58 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this; }, + setScale : function( sx, sy ) { + this.sb_scaleX= sx; + this.sb_scaleY= sy; + return this; + }, + + setScaleAnchor : function( ax, ay ) { + this.sb_scaleAnchorX= ax; + this.sb_scaleAnchorY= ay; + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= ax; + this.tAnchorY= ay; + return this; + }, + + setPositionAnchored : function( x,y,ax,ay ) { + this.tb_x= x; + this.tb_y= y; + this.tAnchorX= ax; + this.tAnchorY= ay; + return this; + }, + + setPosition : function( x,y ) { + this.tb_x= x; + this.tb_y= y; + return this; + }, + setLocation : function( x, y ) { this.tb_x= x; this.tb_y= y; return this; + }, + + flatten : function( npatches, closed ) { + var point= this.getPositionFromLength(0); + var path= new CAAT.Path().beginPath( point.x, point.y ); + for( var i=0; i>0,b[5]>>0);return this},transformRenderingContext_Clamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2]>>0,b[5]>>0);return this}};CAAT.Matrix.prototype.transformRenderingContext=CAAT.Matrix.prototype.transformRenderingContext_Clamp;CAAT.Matrix.prototype.transformRenderingContextSet=CAAT.Matrix.prototype.transformRenderingContextSet_Clamp})(); (function(){CAAT.MatrixStack=function(){this.stack=[];this.saved=[];return this};CAAT.MatrixStack.prototype={stack:null,saved:null,pushMatrix:function(a){this.stack.push(a);return this},popMatrix:function(){return this.stack.pop()},save:function(){this.saved.push(this.stack.length);return this},restore:function(){for(var a=this.saved.pop();this.stack.length!==a;)this.popMatrix();return this},getMatrix:function(){for(var a=new CAAT.Matrix,b=0;b=g)return{r:d,g:e,b:f};a=a+(d-a)/g*h>>0;b=b+(e-b)/g*h>>0;c=c+(f-c)/g*h>>0;a>255?a=255:a<0&&(a=0);b>255?b=255:b<0&&(b=0);c>255?c=255:c<0&&(c=0);return{r:a,g:b,b:c}},makeRGBColorRamp:function(a,b,c){var d=[],e=a.length-1;b/=e;for(var f=0;f>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],m=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,l=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o>0,q=i+n*o>>0,r=j+l*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<< +a[f],h=g>>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],l=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,m=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o>0,q=i+n*o>>0,r=j+m*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<< 24|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY:d.push([q,r,s,p]);break;case this.RampEnumeration.RAMP_CHANNEL_RGB_ARRAY:d.push([q,r,s])}}}return d}}})();(function(){CAAT.Color.RGB=function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this};CAAT.Color.RGB.prototype={r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}})();(function(){CAAT.Rectangle=function(){return this};CAAT.Rectangle.prototype={x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c, d);return this},contains:function(a,b){return a>=0&&a=0&&bthis.y1)this.y1=b;if(a>this.x1)this.x1=a;this.width=this.x1-this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1, -a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1this.x1?false:a.y1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1,a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= -0.5;for(var b=0;bthis.x1?false:a.y1this.y1?false:true},intersectsRect:function(a,b,c,d){return-1===c||-1===d?false:a+c-1this.x1?false:b+d-1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1, +a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= +0.5;for(var b=0;b=0&&ba*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y, a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}})();(function(){CAAT.QuadTree=function(){return this};CAAT.QuadTree.prototype={bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]=(new CAAT.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.QuadTree).create(h, b,c,i,this.bgActors);this.quadData[2]=(new CAAT.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e< +this.rows;e++){this.xycache.push([]);for(c=0;c=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status= -e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a&&a=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e=0;e=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}},calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return""; +CAAT.Behavior.Status.EXPIRED&&e.setExpired(a,b-this.behaviorStartTime)}return this},setFrameTime:function(a,b){CAAT.ContainerBehavior.superclass.setFrameTime.call(this,a,b);for(var c=this.behaviors,d=0;d=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}},calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return""; typeof c==="undefined"&&(c=100);for(var d=null,e="@-"+a+"-keyframes "+b+" {",f,b=0;b<=c;b++)f=this.interpolator.getPosition(b/c).y,d=this.calculateKeyFrameData(f,a,d),f=""+b/c*100+"%{"+d.rules+"}\n",d=d.ret,e+=f;e+="}";return e}};extend(CAAT.ContainerBehavior,CAAT.Behavior,null)})(); (function(){CAAT.RotateBehavior=function(){CAAT.RotateBehavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.RotateBehavior.prototype={startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);this.doValueApplication&&b.setRotationAnchored(c,this.anchorX,this.anchorY);return c},setValues:function(a,b,c,d){this.startAngle=a;this.endAngle= b;if(typeof c!=="undefined"&&typeof d!=="undefined")this.anchorX=c,this.anchorY=d;return this},setAngles:function(a,b){return this.setValues(a,b)},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"rotate("+(this.startAngle+a*(this.endAngle-this.startAngle))+"rad)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<= @@ -110,11 +115,10 @@ d,this.anchorX,this.anchorY);return{scaleX:c,scaleY:d}},setValues:function(a,b,c a*(this.endScaleY-this.startScaleY))+")"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.ScaleBehavior,CAAT.Behavior,null)})(); (function(){CAAT.AlphaBehavior=function(){CAAT.AlphaBehavior.superclass.constructor.call(this);return this};CAAT.AlphaBehavior.prototype={startAlpha:0,endAlpha:0,getPropertyName:function(){return"opacity"},setForTime:function(a,b){var c=this.startAlpha+a*(this.endAlpha-this.startAlpha);this.doValueApplication&&b.setAlpha(c);return c},setValues:function(a,b){this.startAlpha=a;this.endAlpha=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return this.startAlpha+ a*(this.endAlpha-this.startAlpha)},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}};extend(CAAT.AlphaBehavior,CAAT.Behavior,null)})(); -(function(){CAAT.PathBehavior=function(){CAAT.PathBehavior.superclass.constructor.call(this);return this};CAAT.PathBehavior.autorotate={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2};CAAT.PathBehavior.prototype={path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.PathBehavior.autorotate.FREE,translateX:0,translateY:0,getPropertyName:function(){return"translate"},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this}, -setValues:function(a){return this.setPath(a)},setTranslation:function(a,b){this.translateX=a;this.translateY=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+(a.x-this.translateX)+"px) translateY("+(a.y-this.translateY)+"px)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/ -c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.SpriteImage.prototype,h=CAAT.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE): -(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y}):{x:c.x-this.translateX,y:c.y-this.translateY}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a), -this.path.getPosition(a)):{x:-1,y:-1}}};extend(CAAT.PathBehavior,CAAT.Behavior)})();(function(){CAAT.ColorBehavior=function(){return this};CAAT.ColorBehavior.prototype={};extend(CAAT.ColorBehavior,CAAT.Behavior)})(); +(function(){CAAT.PathBehavior=function(){CAAT.PathBehavior.superclass.constructor.call(this);return this};CAAT.PathBehavior.autorotate={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2};CAAT.PathBehavior.prototype={path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.PathBehavior.autorotate.FREE,getPropertyName:function(){return"translate"},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(){return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+a.x+"px) translateY("+a.y+"px)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a); +if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.SpriteImage.prototype,h=CAAT.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL): +(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x,c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}};extend(CAAT.PathBehavior,CAAT.Behavior)})();(function(){CAAT.ColorBehavior=function(){return this};CAAT.ColorBehavior.prototype={};extend(CAAT.ColorBehavior,CAAT.Behavior)})(); (function(){CAAT.Scale1Behavior=function(){CAAT.Scale1Behavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.Scale1Behavior.prototype={startScale:1,endScale:1,anchorX:0.5,anchorY:0.5,sx:1,sy:1,applyOnX:true,getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScale+a*(this.endScale-this.startScale);0===c&&(c=0.01);this.doValueApplication&&(this.applyOnX?b.setScaleAnchored(c,b.scaleY,this.anchorX,this.anchorY):b.setScaleAnchored(b.scaleX, c,this.anchorX,this.anchorY));return c},setValues:function(a,b,c,d,e){this.startScale=a;this.endScale=b;this.applyOnX=!!c;if(typeof d!=="undefined"&&typeof e!=="undefined")this.anchorX=d,this.anchorY=e;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.startScale+a*(this.endScale-this.startScale);return this.applyOnX?"scaleX("+a+")":"scaleY("+a+")"},calculateKeyFramesData:function(a, b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.Scale1Behavior,CAAT.Behavior)})();(function(){CAAT.Debug=function(){return this};CAAT.Debug.prototype={width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'
CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0
Sound
Music
AA Bounding Boxes
Bounding Boxes
Dirty Rects
', @@ -125,53 +129,54 @@ this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this. this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle="black";b.beginPath();b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>> 0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath();b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE* this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}})();(function(){CAAT.Actor=function(){this.behaviorList=[];this.lifecycleListenerList=[];this.AABB=new CAAT.Rectangle;this.viewVertices=[new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0)];this.scaleAnchor=this.ANCHOR_CENTER;this.modelViewMatrix=new CAAT.Matrix;this.worldModelViewMatrix=new CAAT.Matrix;this.resetTransform();this.setScale(1,1);this.setRotation(0);return this};CAAT.Actor.ANCHOR_CENTER=0;CAAT.Actor.ANCHOR_TOP=1;CAAT.Actor.ANCHOR_BOTTOM=2;CAAT.Actor.ANCHOR_LEFT= -3;CAAT.Actor.ANCHOR_RIGHT=4;CAAT.Actor.ANCHOR_TOP_LEFT=5;CAAT.Actor.ANCHOR_TOP_RIGHT=6;CAAT.Actor.ANCHOR_BOTTOM_LEFT=7;CAAT.Actor.ANCHOR_BOTTOM_RIGHT=8;CAAT.Actor.ANCHOR_CUSTOM=9;CAAT.Actor.prototype={lifecycleListenerList:null,behaviorList:null,parent:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,clipPath:null,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1,expired:false, -discardable:false,pointed:false,mouseEnabled:true,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,fillStyle:null,strokeStyle:null,time:0,AABB:null,viewVertices:null,inFrame:false,dirty:true,wdirty:true,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:false,backgroundImage:null,id:null,size_active:1, -size_total:1,__next:null,__d_ax:-1,__d_ay:-1,gestureEnabled:false,invalid:true,cached:false,collides:false,collidesAsRect:true,isAA:true,setupCollission:function(a,b){this.collides=a;this.collidesAsRect=!b},invalidate:function(){this.invalid=true},setGestureEnabled:function(a){this.gestureEnabled=!!a},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent=a;return this},setBackgroundImage:function(a, +3;CAAT.Actor.ANCHOR_RIGHT=4;CAAT.Actor.ANCHOR_TOP_LEFT=5;CAAT.Actor.ANCHOR_TOP_RIGHT=6;CAAT.Actor.ANCHOR_BOTTOM_LEFT=7;CAAT.Actor.ANCHOR_BOTTOM_RIGHT=8;CAAT.Actor.ANCHOR_CUSTOM=9;CAAT.Actor.prototype={lifecycleListenerList:null,behaviorList:null,parent:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,clipPath:null,tAnchorX:0,tAnchorY:0,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1, +expired:false,discardable:false,pointed:false,mouseEnabled:true,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,fillStyle:null,strokeStyle:null,time:0,AABB:null,viewVertices:null,inFrame:false,dirty:true,wdirty:true,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:false,backgroundImage:null,id:null, +size_active:1,size_total:1,__next:null,__d_ax:-1,__d_ay:-1,gestureEnabled:false,invalid:true,cached:false,collides:false,collidesAsRect:true,isAA:true,setupCollission:function(a,b){this.collides=a;this.collidesAsRect=!b},invalidate:function(){this.invalid=true},setGestureEnabled:function(a){this.gestureEnabled=!!a},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent=a;return this},setBackgroundImage:function(a, b){if(a){a instanceof CAAT.SpriteImage||(a=(new CAAT.SpriteImage).initialize(a,1,1));a.setOwner(this);this.backgroundImage=a;if(typeof b==="undefined"||b)this.width=a.getWidth(),this.height=a.getHeight();this.glEnabled=true}else this.backgroundImage=null;return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.invalidate());return this},setBackgroundImageOffset:function(a,b){this.backgroundImage&&this.backgroundImage.setOffset(a,b);return this},setAnimationImageIndex:function(a){this.backgroundImage&& this.backgroundImage.setAnimationImageIndex(a);return this},setChangeFPS:function(a){this.backgroundImage&&this.backgroundImage.setChangeFPS(a);return this},setImageTransformation:function(a){this.backgroundImage&&this.backgroundImage.setSpriteTransformation(a);return this},centerOn:function(a,b){this.setLocation(a-this.width/2,b-this.height/2);return this},centerAt:function(a,b){return this.centerOn(a,b)},getTextureGLPage:function(){return this.backgroundImage.image.__texturePage},setVisible:function(a){this.visible= a;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},removeListener:function(a){for(var b=this.lifecycleListenerList.length;b--;)if(this.lifecycleListenerList[b]===a){this.lifecycleListenerList.splice(b,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=a;return this},fireEvent:function(a,b){for(var c=0;c=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&b>=0&&ae)e=c.x;if(c.yg)g=c.y;c=b[1];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[2];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[3];if(c.xe)e=c.x;if(c.yg)g=c.y;a.x=d;a.y=f;a.x1=e;a.y1=g;a.width=e-d;a.height=g-f;return this},paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha* -this.alpha:1;c.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(c);this.worldModelViewMatrix.transformRenderingContext(c);this.clip&&(c.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):c.rect(0,0,this.width,this.height),c.clip());this.paint(a,b);return true},__paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.alpha;var d=this.worldModelViewMatrix.matrix;c.setTransform(d[0],d[3],d[1],d[4],d[2],d[5],this.frameAlpha);this.paint(a,b); -return true},paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);if(!this.__vv)this.__vv=new Float32Array(12);this.setGLCoords(this.__vv,0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var b=a.coordsIndex;this.setGLCoords(a.coords,b);a.coordsIndex=b+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,b){var c= -this.viewVertices;a[b++]=c[0].x;a[b++]=c[0].y;a[b++]=0;a[b++]=c[1].x;a[b++]=c[1].y;a[b++]=0;a[b++]=c[2].x;a[b++]=c[2].y;a[b++]=0;a[b++]=c[3].x;a[b++]=c[3].y;a[b++]=0},setUV:function(a,b){this.backgroundImage.setUV(a,b)},glNeedsFlush:function(a){return this.getTextureGLPage()!==a.currentTexturePage?true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var b=this.getTextureGLPage();b!==a.currentTexturePage&&a.setGLTexturePage(b);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)}, -endAnimate:function(){return this},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this},setClip:function(a,b){this.clip=a;this.clipPath=b;return this},cacheAsBitmap:function(a){var a=a||0,b=document.createElement("canvas");b.width=this.width;b.height=this.height;var c=b.getContext("2d");this.paintActor({ctx:c,crc:c,modelViewMatrix:new CAAT.Matrix},a);this.setBackgroundImage(b);this.cached=true;return this},setAsButton:function(a,b,c,d,e,f){this.setBackgroundImage(a,true);this.iNormal= -b||0;this.iOver=c||b;this.iPress=d||b;this.iDisabled=e||b;this.fnOnClick=f;this.enabled=true;this.setSpriteIndex(b);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&&null!==this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&& -(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a;this.iOver=b;this.iPress=c;this.iDisabled=d;this.setSpriteIndex(this.iNormal);return this};return this}};if(CAAT.NO_PERF)CAAT.Actor.prototype.paintActor= -CAAT.Actor.prototype.__paintActor})(); +b=0}return{x:b,y:c}},setGlobalAnchor:function(a,b){this.scaleTX=this.rotationX=this.tAnchorX=a;this.scaleTY=this.rotationY=this.tAnchorY=b;this.dirty=true;return this},setScaleAnchor:function(a,b){this.scaleTX=a;this.scaleTY=b;this.dirty=true;return this},setScaleAnchored:function(a,b,c,d){this.scaleTX=c;this.scaleTY=d;this.scaleX=a;this.scaleY=b;this.dirty=true;return this},setRotationAnchor:function(a,b){this.rotationX=b;this.rotationY=a;this.dirty=true;return this},setRotation:function(a){this.rotationAngle= +a;this.dirty=true;return this},setRotationAnchored:function(a,b,c){this.rotationAngle=a;this.rotationX=b;this.rotationY=c;this.dirty=true;return this},setSize:function(a,b){this.width=a|0;this.height=b|0;this.dirty=true;return this},setBounds:function(a,b,c,d){this.x=a;this.y=b;this.width=c;this.height=d;this.dirty=true;return this},setLocation:function(a,b){this.x=a;this.y=b;this.oldX=a;this.oldY=b;this.dirty=true;return this},setPosition:function(a,b){return this.setLocation(a,b)},setPositionAnchor:function(a, +b){this.tAnchorX=a;this.tAnchorY=b;return this},setPositionAnchored:function(a,b,c,d){this.setLocation(a,b);this.tAnchorX=c;this.tAnchorY=d;return this},isInAnimationFrame:function(a){if(this.expired)return false;if(this.duration===Number.MAX_VALUE)return this.start_time<=a;return a>=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&b>=0&&ae)e=c.x;if(c.yg)g=c.y;c=b[1];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[2];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[3];if(c.x< +d)d=c.x;if(c.x>e)e=c.x;if(c.yg)g=c.y;a.x=d;a.y=f;a.x1=e;a.y1=g;a.width=e-d;a.height=g-f;return this},paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;c.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(c);this.worldModelViewMatrix.transformRenderingContext(c);this.clip&&(c.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):c.rect(0,0,this.width,this.height),c.clip());this.paint(a, +b);return true},__paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.alpha;var d=this.worldModelViewMatrix.matrix;c.setTransform(d[0],d[3],d[1],d[4],d[2],d[5],this.frameAlpha);this.paint(a,b);return true},paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);if(!this.__vv)this.__vv=new Float32Array(12);this.setGLCoords(this.__vv, +0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var b=a.coordsIndex;this.setGLCoords(a.coords,b);a.coordsIndex=b+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,b){var c=this.viewVertices;a[b++]=c[0].x;a[b++]=c[0].y;a[b++]=0;a[b++]=c[1].x;a[b++]=c[1].y;a[b++]=0;a[b++]=c[2].x;a[b++]=c[2].y;a[b++]=0;a[b++]=c[3].x;a[b++]=c[3].y;a[b++]=0},setUV:function(a,b){this.backgroundImage.setUV(a,b)},glNeedsFlush:function(a){return this.getTextureGLPage()!==a.currentTexturePage? +true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var b=this.getTextureGLPage();b!==a.currentTexturePage&&a.setGLTexturePage(b);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)},endAnimate:function(){return this},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this},setClip:function(a,b){this.clip=a;this.clipPath=b;return this},cacheAsBitmap:function(a){var a=a||0,b=document.createElement("canvas");b.width=this.width;b.height=this.height; +var c=b.getContext("2d");this.paintActor({ctx:c,crc:c,modelViewMatrix:new CAAT.Matrix},a);this.setBackgroundImage(b);this.cached=true;return this},setAsButton:function(a,b,c,d,e,f){this.setBackgroundImage(a,true);this.iNormal=b||0;this.iOver=c||b;this.iPress=d||b;this.iDisabled=e||b;this.fnOnClick=f;this.enabled=true;this.setSpriteIndex(b);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&& +null!==this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag= +function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a;this.iOver=b;this.iPress=c;this.iDisabled=d;this.setSpriteIndex(this.iNormal);return this};return this}};if(CAAT.NO_PERF)CAAT.Actor.prototype.paintActor=CAAT.Actor.prototype.__paintActor})(); (function(){CAAT.ActorContainer=function(a){CAAT.ActorContainer.superclass.constructor.call(this);this.childrenList=[];this.pendingChildrenList=[];if(typeof a!=="undefined")this.addHint=a,this.boundingBox=new CAAT.Rectangle;return this};CAAT.ActorContainer.AddHint={CONFORM:1};CAAT.ActorContainer.prototype={childrenList:null,activeChildren:null,pendingChildrenList:null,addHint:0,boundingBox:null,runion:new CAAT.Rectangle,drawScreenBoundingBox:function(a,b){if(this.inFrame){for(var c=this.childrenList, d=0;d=this.childrenList.length)b=this.childrenList.length; -a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList,b=a.length-1;b>=0;b--)a[b].destroy();CAAT.ActorContainer.superclass.destroy.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},getChildAt:function(a){return this.childrenList[a]}, -setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c)if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}}}};if(CAAT.NO_PERF)CAAT.ActorContainer.prototype.paintActor=CAAT.ActorContainer.prototype.__paintActor;extend(CAAT.ActorContainer,CAAT.Actor,null)})(); +a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList,b=a.length-1;b>=0;b--)a[b].destroy();CAAT.ActorContainer.superclass.destroy.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length}, +getChildAt:function(a){return this.childrenList[a]},setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c)if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}}}};if(CAAT.NO_PERF)CAAT.ActorContainer.prototype.paintActor=CAAT.ActorContainer.prototype.__paintActor;extend(CAAT.ActorContainer,CAAT.Actor,null)})(); (function(){CAAT.TextActor=function(){CAAT.TextActor.superclass.constructor.call(this);this.font="10px sans-serif";this.textAlign="left";this.textBaseline="top";this.outlineColor="black";this.clip=false;return this};CAAT.TextActor.TRAVERSE_PATH_FORWARD=1;CAAT.TextActor.TRAVERSE_PATH_BACKWARD=-1;CAAT.TextActor.prototype={font:null,textAlign:null,textBaseline:null,fill:true,textFillStyle:"#eee",text:null,textWidth:0,textHeight:0,outline:false,outlineColor:null,path:null,pathInterpolator:null,pathDuration:1E4, sign:1,setFill:function(a){this.fill=a;return this},setTextFillStyle:function(a){this.textFillStyle=a;return this},setOutline:function(a){this.outline=a;return this},setPathTraverseDirection:function(a){this.sign=a;return this},setOutlineColor:function(a){this.outlineColor=a;return this},setText:function(a){this.text=a;if(null===this.text||this.text==="")this.width=this.height=0;this.calcTextSize(CAAT.director[0]);return this},setTextAlign:function(a){this.textAlign=a;return this},setAlign:function(a){return this.setTextAlign(a)}, -setTextBaseline:function(a){this.textBaseline=a;return this},setBaseline:function(a){return this.setTextBaseline(a)},setFont:function(a){a||(a="10px sans-serif");this.font=a;this.calcTextSize(CAAT.director[0]);return this},calcTextSize:function(a){if(typeof this.text==="undefined"||null===this.text||""===this.text)return this.textHeight=this.textWidth=0,this;if(a.glEnabled)return this;a=a.ctx;a.save();a.font=this.font;this.textWidth=a.measureText(this.text).width;if(this.width===0)this.width=this.textWidth; -try{var b=this.font.substring(0,this.font.indexOf("px"));this.textHeight=parseInt(b,10);this.textHeight+=this.textHeight/4>>0}catch(c){this.textHeight=20}if(this.height===0)this.height=this.textHeight;a.restore();return this},paint:function(a,b){CAAT.TextActor.superclass.paint.call(this,a,b);if(!this.cached&&null!==this.text){(this.textWidth===0||this.textHeight===0)&&this.calcTextSize(a);var c=a.ctx;if(typeof this.font==="object")return this.drawSpriteText(a,b);if(null!==this.font)c.font=this.font; -if(null!==this.textAlign)c.textAlign=this.textAlign;if(null!==this.textBaseline)c.textBaseline=this.textBaseline;if(this.fill&&null!==this.textFillStyle)c.fillStyle=this.textFillStyle;if(this.outline&&null!==this.outlineColor)c.strokeStyle=this.outlineColor;if(null===this.path){var d=0;if(this.textAlign==="center")d=this.width/2|0;else if(this.textAlign==="right")d=this.width;if(this.fill)c.fillText(this.text,d,0),this.outline&&(c.beginPath(),c.strokeText(this.text,d,0));else{if(null!==this.outlineColor)c.strokeStyle= -this.outlineColor;c.beginPath();c.strokeText(this.text,d,0)}}else this.drawOnPath(a,b)}},drawOnPath:function(a,b){for(var c=a.ctx,d=this.sign*this.pathInterpolator.getPosition(b%this.pathDuration/this.pathDuration).y*this.path.getLength(),e=new CAAT.Point(0,0,0),f=new CAAT.Point(0,0,0),g=0;g>0}catch(c){this.textHeight=20}if(this.height===0)this.height=this.textHeight;a.restore();return this},paint:function(a,b){CAAT.TextActor.superclass.paint.call(this,a,b);if(!this.cached&&null!==this.text){(this.textWidth=== +0||this.textHeight===0)&&this.calcTextSize(a);var c=a.ctx;if(this.font instanceof CAAT.SpriteImage)return this.drawSpriteText(a,b);if(null!==this.font)c.font=this.font;if(null!==this.textAlign)c.textAlign=this.textAlign;if(null!==this.textBaseline)c.textBaseline=this.textBaseline;if(this.fill&&null!==this.textFillStyle)c.fillStyle=this.textFillStyle;if(this.outline&&null!==this.outlineColor)c.strokeStyle=this.outlineColor;if(null===this.path){var d=0;if(this.textAlign==="center")d=this.width/2|0; +else if(this.textAlign==="right")d=this.width;if(this.fill)c.fillText(this.text,d,0),this.outline&&(c.beginPath(),c.strokeText(this.text,d,0));else{if(null!==this.outlineColor)c.strokeStyle=this.outlineColor;c.beginPath();c.strokeText(this.text,d,0)}}else this.drawOnPath(a,b)}},drawOnPath:function(a,b){for(var c=a.ctx,d=this.sign*this.pathInterpolator.getPosition(b%this.pathDuration/this.pathDuration).y*this.path.getLength(),e=new CAAT.Point(0,0,0),f=new CAAT.Point(0,0,0),g=0;gd+this.range?this.minSize:a===d?th this.ttask)this.ttask.cancel(),this.ttask=null},addChild:function(a){var b=this;a.__Dock_mouseEnter=a.mouseEnter;a.__Dock_mouseExit=a.mouseExit;a.__Dock_mouseMove=a.mouseMove;a.mouseEnter=function(a){b.actorMouseEnter(a);this.__Dock_mouseEnter(a)};a.mouseExit=function(a){b.actorMouseExit(a);this.__Dock_mouseExit(a)};a.mouseMove=function(a){b.actorPointed(a.point.x,a.point.y,a.source);this.__Dock_mouseMove(a)};a.width=this.minSize;a.height=this.minSize;return CAAT.Dock.superclass.addChild.call(this, a)}};extend(CAAT.Dock,CAAT.ActorContainer,null)})();(function(){CAAT.Director=function(){CAAT.Director.superclass.constructor.call(this);this.browserInfo=new CAAT.BrowserDetect;this.audioManager=(new CAAT.AudioManager).initialize(8);this.scenes=[];this.mousePoint=new CAAT.Point(0,0,0);this.prevMousePoint=new CAAT.Point(0,0,0);this.screenMousePoint=new CAAT.Point(0,0,0);this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Rectangle);this.dirtyRectsIndex= 0;return this};CAAT.Director.CLEAR_DIRTY_RECTS=1;CAAT.Director.CLEAR_ALL=true;CAAT.Director.CLEAR_NONE=false;CAAT.Director.prototype={debug:false,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false,lastSelectedActor:null,dragging:false,scenes:null,currentScene:null,canvas:null,crc:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:true,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null, -glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,size_dirtyRects:0,draws:0},currentTexturePage:0,currentOpacity:1,intervalId:null,frameCounter:0,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,nDirtyRects:0,collidingActors:null, -solveCollissions:function(){},addCollidingActor:function(a){this.collidingActors.push(a)},checkDebug:function(){if(CAAT.DEBUG){var a=(new CAAT.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){switch(this.resize){case this.RESIZE_WIDTH:this.setBounds(0,0,a,this.height);break;case this.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case this.RESIZE_BOTH:this.setBounds(0,0,a,b);break; -case this.RESIZE_PROPORTIONAL:this.setScaleProportional(a,b)}this.glEnabled&&this.glReset();if(this.onResizeCallback)this.onResizeCallback(this,a,b)},setScaleProportional:function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");this.glEnabled&&this.glReset()},enableResizeEvents:function(a, -b){a===this.RESIZE_BOTH||a===this.RESIZE_WIDTH||a===this.RESIZE_HEIGHT||a===this.RESIZE_PROPORTIONAL?(this.referenceWidth=this.width,this.referenceHeight=this.height,this.resize=a,CAAT.registerResizeListener(this),this.onResizeCallback=b,this.windowResized(window.innerWidth,window.innerHeight)):(CAAT.unregisterResizeListener(this),this.onResizeCallback=null)},setBounds:function(a,b,c,d){CAAT.Director.superclass.setBounds.call(this,a,b,c,d);this.canvas.width=c;this.canvas.height=d;this.crc=this.ctx= -this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");for(a=0;a=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total= -0;this.statistics.size_active=0;this.statistics.draws=0},render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0}, +render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0)f.clip(),f.fillStyle="rgba(160,255,150,.4)",f.fillRect(0,0,this.width,this.height)}f.restore()}this.frameCounter++},animate:function(){this.setModelViewMatrix(this);this.setScreenBounds(); -this.invalid=this.dirty=false;this.dirtyRectsIndex=-1;this.cDirtyRects=[];this.collidingActors=[];for(var a=this.childrenList,b,c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width, -this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;a.restore();this.ctx=c;this.crc=d}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&& -this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene;a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform();a.setLocation(0, -0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e<0.33?(e=CAAT.Scene.prototype.EASE_ROTATION, -g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE, -h=(new CAAT.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)},setScene:function(a){a=this.scenes[a]; -this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)},switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene); -this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled= -true;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"):null,/^(fixed)$/.test(g))break;else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset"); -return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI= -this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x, -this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x, -b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x= -c.x;this.prevMousePoint.y=c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, -this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y, -a,b,this.screenMousePoint,this.currentScene.time)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time);this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_= -this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y, -0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)}, -__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0, +0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;a.restore();this.ctx=c;this.crc=d}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null=== +this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene;a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform(); +a.setLocation(0,0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e< +0.33?(e=CAAT.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)): +(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)}, +setScene:function(a){a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)},switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a, +b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b)}, +endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled=true;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"):null,/^(fixed)$/.test(g))break; +else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset");return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+ +document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c= +b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a), +c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0));this.dragging=true;var e=b.x,f=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),d));this.prevMousePoint.x=c.x;this.prevMousePoint.y=c.y;if(e===b.x&&f===b.y){e=b.contains(c.x,c.y);if(this.in_&&!e)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=false;if(!this.in_&&e)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=true}}else this.in_= +true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,d))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint, +d)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time); +this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_=this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScane?this.currentScene.time: +0),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor, +this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b>0)*e;var k=i+(d/h>>0)*f,m=g+e,n=k+f;g=(new CAAT.SpriteImageHelper(g,k,m-g,n-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,n/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(g-=e);var h=this.offsetY%f;h>0&&(h-=f);var e=((this.ownerActor.width-g)/e>>0)+1,f=((this.ownerActor.height-h)/f>>0)+1,i,j;for(i=0;i>0,d+h+i* -b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width, -b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image, -b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return"-"+(a.x-this.offsetX)+"px -"+(a.y-this.offsetY)+"px "+(this.transformation===this.TR_TILE? -"":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]= -g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;switch(a){case this.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case this.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case this.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case this.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case this.TR_TILE:this.paint=this.paintTiled;break; -default:this.paint=this.paintN}return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1)this.prevAnimationTime===-1?(this.prevAnimationTime=a,this.spriteIndex=0):(a-=this.prevAnimationTime,a/=this.changeFPS,a%=this.animationImageIndex.length,this.spriteIndex=this.animationImageIndex[Math.floor(a)])},getMapInfo:function(a){return this.mapInfo[a]}, -initializeFromMap:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b)d=b[c],d=new CAAT.SpriteImageHelper(d.x,d.y,d.width,d.height,a.width,a.height),this.mapInfo[c]=d,e||this.setAnimationImageIndex([c]),e++;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.SpriteImageHelper(f.x,f.y,f.width,f.height,a.width,a.height);d.xoffset=typeof f.xoffset==="undefined"?0:f.xoffset;d.yoffset=typeof f.yoffset==="undefined"?0:f.yoffset; -d.xadvance=typeof f.xadvance==="undefined"?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>0,f=0;f=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)):this.callback_tick&&this.callback_tick(a, +a.__dv=this.singleHeight/a.__texturePage.height;e=this.singleWidth;f=this.singleHeight;var h=this.columns;if(a.inverted)d=e,e=f,f=d,h=this.rows;var a=this.image.__tx,i=this.image.__ty,j=this.image.__texturePage;for(d=0;d>0)*e;var k=i+(d/h>>0)*f,l=g+e,n=k+f;g=(new CAAT.SpriteImageHelper(g,k,l-g,n-k,j.width,j.height)).setGL(g/j.width,k/j.height,l/j.width,n/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(g-=e);var h=(this.offsetY-this.ownerActor.y)%f;h>0&&(h-=f);var e=((d.width-g)/e>>0)+1,f=((d.height-h)/f>>0)+1,i,j,k=a.ctx;for(i=0;i>0,d.y-this.ownerActor.y+h+i*c.height>>0,c.width,c.height)},paintInvertedH:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex]; +a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this}, +paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex]; +return"-"+(a.x-this.offsetX)+"px -"+(a.y-this.offsetY)+"px "+(this.transformation===this.TR_TILE?"":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v, +h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;switch(a){case this.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case this.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case this.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case this.TR_FIXED_TO_SIZE:this.paint= +this.paintScaled;break;case this.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1)this.prevAnimationTime===-1?(this.prevAnimationTime=a,this.spriteIndex=0):(a-=this.prevAnimationTime,a/=this.changeFPS,a%=this.animationImageIndex.length,this.spriteIndex= +this.animationImageIndex[Math.floor(a)])},getMapInfo:function(a){return this.mapInfo[a]},initializeFromMap:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b)d=b[c],d=new CAAT.SpriteImageHelper(d.x,d.y,d.width,d.height,a.width,a.height),this.mapInfo[c]=d,e||this.setAnimationImageIndex([c]),e++;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.SpriteImageHelper(f.x,f.y,f.width,f.height,a.width,a.height);d.xoffset=typeof f.xoffset=== +"undefined"?0:f.xoffset;d.yoffset=typeof f.yoffset==="undefined"?0:f.yoffset;d.xadvance=typeof f.xadvance==="undefined"?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>0,f=0;fa&&(a=c)}return this.fontHeight=a},drawString:function(a,b,c,d){for(var e, +f,g=b.split(""),b=0;b=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)):this.callback_tick&&this.callback_tick(a, b,this);return this},reset:function(a){this.remove=false;this.startTime=a;this.scene.ensureTimerTask(this);return this},cancel:function(){this.remove=true;null!=this.callback_cancel&&this.callback_cancel(this.scene.time,this.scene.time-this.startTime,this);return this}}})();(function(){CAAT.Scene=function(){CAAT.Scene.superclass.constructor.call(this);this.timerList=[];this.fillStyle=null;return this};CAAT.Scene.prototype={easeContainerBehaviour:null,easeContainerBehaviourListener:null,easeIn:false,EASE_ROTATION:1,EASE_SCALE:2,EASE_TRANSLATE:3,timerList:null,timerSequence:0,paused:false,isPaused:function(){return this.paused},setPaused:function(a){this.paused=a},checkTimers:function(a){for(var b=this.timerList,c=b.length-1;c>=0;)b[c].remove||b[c].checkTask(a),c--},ensureTimerTask:function(a){this.hasTimer(a)|| this.timerList.push(a);return this},hasTimer:function(a){for(var b=this.timerList,c=b.length-1;c>=0;){if(b[c]===a)return true;c--}return false},createTimer:function(a,b,c,d,e){a=(new CAAT.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=this.time;a.scene=this;this.timerList.push(a);return a},removeExpiredTimers:function(){var a,b=this.timerList;for(a=0;a=this.inputList.length&&(b=this.inputList.length-1);b=this.inputList[b];typeof c==="undefined"||c>=b.length?b.push(a):c<=0?b.unshift(a):b.splice(c,0,a);return this},emptyInputList:function(a){a<0?a=0:a>=this.inputList.length&&(a=this.inputList.length-1);this.inputList[a]=[];return this},removeActorFromInputList:function(a,b){if(typeof b==="undefined"){var c,d;for(c=0;c=this.inputList.length&&(b=this.inputList.length-1);e=this.inputList[b];for(d=0;dthis.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-ethis.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-ed?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil={};CAAT.modules.ImageUtil.createAlphaSpriteSheet=function(a,b,c,d,e){if(a>=0;var d=true,e=true,f=true,g=true;if(typeof c!=="undefined"){if(typeof c.top!== -"undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,n=c.width-1,l=false;if(d){for(d=0;db){l=true;break}if(l)break}a= -d}if(e){l=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){l=true;break}if(l)break}k=d}if(f){l=false;for(j=0;jb){l=true;break}if(l)break}m=j}if(g){l=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}n=j}if(0===m&&0===a&&c.width-1===n&&c.height-1===k)return c;b=n-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height=e;h=c.getContext("2d");h.putImageData(f,0,0); +"undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,l=0,n=c.width-1,m=false;if(d){for(d=0;db){m=true;break}if(m)break}a= +d}if(e){m=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){m=true;break}if(m)break}k=d}if(f){m=false;for(j=0;jb){m=true;break}if(m)break}l=j}if(g){m=false;for(j=c.width-1;j>=l;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){m=true;break}if(m)break}n=j}if(0===l&&0===a&&c.width-1===n&&c.height-1===k)return c;b=n-l+1;e=k-a+1;f=h.getImageData(l,a,b,e);c.width=b;c.height=e;h=c.getContext("2d");h.putImageData(f,0,0); return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}})();(function(){CAAT.Font=function(){return this};CAAT.Font.prototype={fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,padding:0,image:null,charMap:null,height:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle= a;return this},createDefault:function(a){for(var b="",c=32;c<128;c++)b+=String.fromCharCode(c);return this.create(b,a)},create:function(a,b){this.padding=b;var c=document.createElement("canvas");c.width=1;c.height=1;var d=c.getContext("2d");d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;var e=0,f=[],g,h;for(g=0;g>0)+1)+2*b,f.push(h),e+=h;c.width=e;c.height=this.fontSize*1.5>>0;d=c.getContext("2d"); d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.crc;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x, -this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),c.arc(this.points[0].x,this.points[0].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.arc(this.points[1].x,this.points[1].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill();c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0];else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone()); +startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color; +c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0];else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone()); return a}};extend(CAAT.LinearPath,CAAT.PathSegment)})(); (function(){CAAT.CurvePath=function(){CAAT.CurvePath.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.CurvePath.prototype={curve:null,newPosition:null,applyAsPath:function(a){this.curve.applyAsPath(a);return this},setPoint:function(a,b){this.curve&&this.curve.setPoint(a,b)},setPoints:function(a){var b=new CAAT.Bezier;b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.Bezier;g.setQuadric(a,b,c,d,e,f);this.curve=g;this.updatePath(); return this},setCubic:function(a,b,c,d,e,f,g,h){var i=new CAAT.Bezier;i.setCubic(a,b,c,d,e,f,g,h);this.curve=i;this.updatePath();return this},updatePath:function(){this.curve.update();this.length=this.curve.getLength();this.curve.getBoundingBox(this.bbox);return this},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition,a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x}, -finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]},endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/ +finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]},endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/ a,y:this.getPosition(c/a).y});return b}};extend(CAAT.CurvePath,CAAT.PathSegment,null)})(); (function(){CAAT.ShapePath=function(){CAAT.ShapePath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point;return this};CAAT.ShapePath.prototype={points:null,length:-1,cw:true,bbox:null,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x, this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x,this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1;a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c, -b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;f1||a<0)a%=1;a<0&&(a=1+a);for(var b=false,c=0;c0?this.pathSegmentStartTime[b]=this.pathSegmentStartTime[b-1]+this.pathSegmentDurationTime[b-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[b].endPath();this.extractPathPoints();return this},press:function(a,b){if(this.interactive){for(var c= -CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b1||a<0)a%=1;a<0&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,i;e!==f;)if(g=(f+e)/2|0,i=c[g],i<=a&&a<=i+d[g])return a=d[g]?(a-i)/d[g]:0,a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;else a0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();typeof b!=="undefined"&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b0.5;this.b2=Math.random()>0.5;this.b3=Math.random()>0.5;this.b4= Math.random()>0.5;this.spd1=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd2=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd3=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd4=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.i1=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i2=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i3=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i4=Math.floor((Math.random()* -2.4+1)*(Math.random()<0.5?1:-1))},apply:function(a,b){var c=0;this.tpos1=this.pos1;this.tpos2=this.pos2;for(var d=this.bufferImage,e=this.m_colorMap,f=this.wavetable,g,h=0;h> -1;break;case 2:f=this.height-1}switch(this.m_alignv){case 0:g=0;break;case 1:g=this.width>>1;break;case 2:g=this.width-1}for(var c=(this.width>>1<<8)-e*g+b*f&65535,f=(this.height>>1<<8)-b*g-e*f&65535,g=this.sourceImageData.width,h=this.sourceImageData.data,i=this.bufferImage,j,k,m;d>this.shift&this.mask)*g+(k>>this.shift&this.mask),j<<=2,i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],k+=e,m+=b;a+=this.distortion;c-=b;f+= +1;break;case 2:f=this.height-1}switch(this.m_alignv){case 0:g=0;break;case 1:g=this.width>>1;break;case 2:g=this.width-1}for(var c=(this.width>>1<<8)-e*g+b*f&65535,f=(this.height>>1<<8)-b*g-e*f&65535,g=this.sourceImageData.width,h=this.sourceImageData.data,i=this.bufferImage,j,k,l;d>this.shift&this.mask)*g+(k>>this.shift&this.mask),j<<=2,i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],k+=e,l+=b;a+=this.distortion;c-=b;f+= e-a}},apply:function(a,b){null!==this.sourceImageData&&this.rotoZoom(a,b);return CAAT.IMRotoZoom.superclass.apply.call(this,a,b)},setCenter:function(){var a=Math.random();this.m_alignv=a<0.33?0:a<0.66?1:2;a=Math.random();this.m_alignh=a<0.33?0:a<0.66?1:2}};extend(CAAT.IMRotoZoom,CAAT.ImageProcessor,null)})();(function(){CAAT.Program=function(a){this.gl=a;return this};CAAT.Program.prototype={shaderProgram:null,gl:null,setAlpha:function(){},getShader:function(a,b,c){if(b==="x-shader/x-fragment")b=a.createShader(a.FRAGMENT_SHADER);else if(b==="x-shader/x-vertex")b=a.createShader(a.VERTEX_SHADER);else return null;a.shaderSource(b,c);a.compileShader(b);return!a.getShaderParameter(b,a.COMPILE_STATUS)?(alert(a.getShaderInfoLog(b)),null):b},getDomShader:function(a,b){var c=document.getElementById(b);if(!c)return null; for(var d="",e=c.firstChild;e;)e.nodeType===3&&(d+=e.textContent),e=e.nextSibling;if(c.type==="x-shader/x-fragment")c=a.createShader(a.FRAGMENT_SHADER);else if(c.type==="x-shader/x-vertex")c=a.createShader(a.VERTEX_SHADER);else return null;a.shaderSource(c,d);a.compileShader(c);return!a.getShaderParameter(c,a.COMPILE_STATUS)?(alert(a.getShaderInfoLog(c)),null):c},initialize:function(){return this},getFragmentShader:function(){return null},getVertexShader:function(){return null},create:function(){var a= this.gl;this.shaderProgram=a.createProgram();a.attachShader(this.shaderProgram,this.getVertexShader());a.attachShader(this.shaderProgram,this.getFragmentShader());a.linkProgram(this.shaderProgram);a.useProgram(this.shaderProgram);return this},setMatrixUniform:function(a){this.gl.uniformMatrix4fv(this.shaderProgram.pMatrixUniform,false,new Float32Array(a.flatten()))},useProgram:function(){this.gl.useProgram(this.shaderProgram);return this}}})(); diff --git a/build/caat.js b/build/caat.js index af908d6b..78b98cba 100644 --- a/build/caat.js +++ b/build/caat.js @@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 65 +Version: 0.3 build: 213 Created on: -DATE: 2012-02-09 -TIME: 20:35:01 +DATE: 2012-02-23 +TIME: 17:38:26 */ @@ -41,7 +41,6 @@ TIME: 20:35:01 */ var CAAT= CAAT || {}; - /** * Common bind function. Allows to set an object's function as callback. Set for every function in the * javascript context. @@ -66,7 +65,6 @@ Function.prototype.bind= Function.prototype.bind || function() { */ function extend(subc, superc) { var subcp = subc.prototype; -CAAT.Color // Class pattern. var F = function() { @@ -1636,6 +1634,31 @@ var cp1= proxy( return true; }, + + intersectsRect : function( x,y,w,h ) { + if ( -1===w || -1===h ) { + return false; + } + + var x1= x+w-1; + var y1= y+h-1; + + if ( x1< this.x ) { + return false; + } + if ( x > this.x1 ) { + return false; + } + if ( y1< this.y ) { + return false; + } + if ( y> this.y1 ) { + return false; + } + + return true; + }, + intersect : function( i, r ) { if ( typeof r==='undefined' ) { r= new CAAT.Rectangle(); @@ -1705,10 +1728,14 @@ var cp1= proxy( ctx.lineTo( this.coordlist[3].x, this.coordlist[3].y ); ctx.stroke(); } - + + ctx.globalAlpha=0.5; for( var i=0; i - * Incomplete class, do not use. + * This object manages one single catmull rom segment, that is 4 points. + * A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points. * * @constructor * @extends CAAT.Curve @@ -2097,26 +2126,19 @@ var cp1= proxy( /** * Set curve control points. - * @param cp0x {number} - * @param cp0y {number} - * @param cp1x {number} - * @param cp1y {number} - * @param cp2x {number} - * @param cp2y {number} - * @param cp3x {number} - * @param cp3y {number} + * @param points Array */ - setCurve : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) { - + setCurve : function( p0, p1, p2, p3 ) { + this.coordlist= []; - - this.coordlist.push( new CAAT.Point().set(cp0x, cp0y ) ); - this.coordlist.push( new CAAT.Point().set(cp1x, cp1y ) ); - this.coordlist.push( new CAAT.Point().set(cp2x, cp2y ) ); - this.coordlist.push( new CAAT.Point().set(cp3x, cp3y ) ); - - this.cubic= true; + this.coordlist.push( p0 ); + this.coordlist.push( p1 ); + this.coordlist.push( p2 ); + this.coordlist.push( p3 ); + this.update(); + + return this; }, /** * Paint the contour by solving again the entire curve. @@ -2124,9 +2146,12 @@ var cp1= proxy( */ paint: function(director) { - var x1,x2,y1,y2; - x1 = this.coordlist[0].x; - y1 = this.coordlist[0].y; + var x1,y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; var ctx= director.ctx; @@ -2135,7 +2160,7 @@ var cp1= proxy( ctx.moveTo(x1,y1); var point= new CAAT.Point(); - + for(var t=this.k;t<=1+this.k;t+=this.k){ this.solve(point,t); ctx.lineTo(point.x,point.y); @@ -2152,19 +2177,17 @@ var cp1= proxy( * @param t {number} a number in the range 0..1 */ solve: function(point,t) { - var t2= t*t; - var t3= t*t2; - var c= this.coordlist; -// q(t) = 0.5 *( (2 * P1) + -// (-P0 + P2) * t + -// (2*P0 - 5*P1 + 4*P2 - P3) * t2 + -// (-P0 + 3*P1- 3*P2 + P3) * t3) + // Handy from CAKE. Thanks. + var af = ((-t+2)*t-1)*t*0.5 + var bf = (((3*t-5)*t)*t+2)*0.5 + var cf = ((-3*t+4)*t+1)*t*0.5 + var df = ((t-1)*t*t)*0.5 + + point.x= c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y= c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; - point.x= 0.5*( (2*c[1].x) + (-c[0].x+c[2].x)*t + (2*c[0].x - 5*c[1].x + 4*c[2].x - c[3].x)*t2 + (-c[0].x + 3*c[1].x - 3*c[2].x + c[3].x)*t3 ); - point.y= 0.5*( (2*c[1].y) + (-c[0].y+c[2].y)*t + (2*c[0].y - 5*c[1].y + 4*c[2].y - c[3].y)*t2 + (-c[0].y + 3*c[1].y - 3*c[2].y + c[3].y)*t3 ); - return point; } @@ -2487,6 +2510,178 @@ var cp1= proxy( }; extend( CAAT.QuadTree, CAAT.Rectangle ); +})(); + +(function() { + + CAAT.SpatialHash= function() { + return this; + }; + + CAAT.SpatialHash.prototype= { + + elements : null, + + width : null, + height : null, + + rows : null, + columns : null, + + xcache : null, + ycache : null, + xycache : null, + + rectangle : null, + r0 : null, + r1 : null, + + initialize : function( w,h, rows,columns ) { + + var i, j; + + this.elements= []; + for( i=0; i>0 ); + } + + this.ycache= []; + for( i=0; i>0 ); + } + + this.xycache=[]; + for( i=0; i * For am exponential interpolation, the getPosition function would look like this: - * function getPosition(time) { return { x:time, y: Math.pow(time,2) }}. + * function getPosition(time) { return { x:time, y: Math.pow(time,2) }Ê}. * meaning that for time=0.5, a value of 0,5*0,5 should use instead. * *

@@ -3066,6 +3261,8 @@ var cp1= proxy( doValueApplication: true, + solved : true, + setValueApplication : function( apply ) { this.doValueApplication= apply; return this; @@ -3123,6 +3320,24 @@ var cp1= proxy( return this; }, + /** + * Sets behavior start time and duration but instead as setFrameTime which sets initial time as absolute time + * regarding scene's time, it uses a relative time offset from current scene time. + * a call to + * setFrameTime( scene.time, duration ) is equivalent to + * setDelayTime( 0, duration ) + * @param delay {number} + * @param duration {number} + */ + setDelayTime : function( delay, duration ) { + this.behaviorStartTime= delay; + this.behaviorDuration= duration; + this.setStatus( CAAT.Behavior.Status.NOT_STARTED ); + this.solved= false; + + return this; + + }, setOutOfFrameTime : function() { this.setStatus( CAAT.Behavior.Status.EXPIRED ); this.behaviorStartTime= Number.MAX_VALUE; @@ -3147,6 +3362,11 @@ var cp1= proxy( */ apply : function( time, actor ) { + if ( !this.solved ) { + this.behaviorStartTime+= time; + this.solved= true; + } + time+= this.timeOffset*this.behaviorDuration; var orgTime= time; @@ -3208,7 +3428,7 @@ var cp1= proxy( var S= CAAT.Behavior.Status; - if ( /*this.expired*/ this.status===S.EXPIRED || this.behaviorStartTime<0 ) { + if ( this.status===S.EXPIRED || this.behaviorStartTime<0 ) { return false; } @@ -3231,7 +3451,7 @@ var cp1= proxy( this.fireBehaviorStartedEvent(actor,time); } - return this.behaviorStartTime<=time && time{ scaleX: {float}, scaleY: {float}} + * @return {object} an object of the form { scaleX: {float}, scaleY: {float}Ê} */ setForTime : function(time,actor) { @@ -4087,9 +4308,6 @@ var cp1= proxy( autoRotateOp: CAAT.PathBehavior.autorotate.FREE, - translateX: 0, - translateY: 0, - getPropertyName : function() { return "translate"; }, @@ -4132,25 +4350,19 @@ var cp1= proxy( }, /** - * This method set an extra offset for the actor traversing the path. - * in example, if you want an actor to traverse the path by its center, and not by default via its top-left corner, - * you should call setTranslation(actor.width/2, actor.height/2);. - * - * Displacement will be substracted from the tarrget coordinate. - * + * @see Acotr.setPositionAcchor + * @deprecated * @param tx a float with xoffset. * @param ty a float with yoffset. */ setTranslation : function( tx, ty ) { - this.translateX= tx; - this.translateY= ty; return this; }, calculateKeyFrameData : function( time ) { time= this.interpolator.getPosition(time).y; var point= this.path.getPosition(time); - return "translateX("+(point.x-this.translateX)+"px) translateY("+(point.y-this.translateY)+"px)" ; + return "translateX("+point.x+"px) translateY("+point.y+"px)" ; }, calculateKeyFramesData : function(prefix, name, keyframessize) { @@ -4185,7 +4397,7 @@ var cp1= proxy( * If autoRotate=true, the actor is rotated as well. The rotation anchor will (if set) always be ANCHOR_CENTER. * @param time an integer indicating the time the behavior is being applied at. * @param actor a CAAT.Actor instance to be translated. - * @return {object} an object of the form { x: {float}, y: {float}}. + * @return {object} an object of the form { x: {float}, y: {float}Ê}. */ setForTime : function(time,actor) { @@ -4209,7 +4421,7 @@ var cp1= proxy( var ay= point.y-this.prevY; if ( ax===0 && ay===0 ) { - actor.setLocation( point.x-this.translateX, point.y-this.translateY ); + actor.setLocation( point.x, point.y ); return { x: actor.x, y: actor.y }; } @@ -4247,12 +4459,12 @@ var cp1= proxy( } if ( this.doValueApplication ) { - actor.setLocation( point.x-this.translateX, point.y-this.translateY ); + actor.setLocation( point.x, point.y ); return { x: actor.x, y: actor.y }; } else { return { - x: point.x-this.translateX, - y: point.y-this.translateY + x: point.x, + y: point.y }; } @@ -4332,7 +4544,7 @@ var cp1= proxy( * * @param time the time to apply the scale for. * @param actor the target actor to Scale. - * @return {object} an object of the form { scaleX: {float}, scaleY: {float}} + * @return {object} an object of the form { scaleX: {float}, scaleY: {float}Ê} */ setForTime : function(time,actor) { @@ -5222,6 +5434,9 @@ var cp1= proxy( clip: false, // should clip the Actor's content against its contour. clipPath: null, + tAnchorX : 0, + tAnchorY : 0, + scaleX: 0, // transformation. width scale parameter scaleY: 0, // transformation. height scale parameter scaleTX: .50, // transformation. scale anchor x position @@ -5320,21 +5535,6 @@ var cp1= proxy( this.parent= parent; return this; }, - - getScene : function() { - if ( typeof this.parent ==='undefined' || this.parent === null) { - return null; - } - - //console.log("this.parent.name " + this.parent.name); - if (this.parent.name === 'CAAT.Scene') { - return this.parent; - } - - return this.parent.getScene(); - }, - - /** * Set this actor's background image. * The need of a background image is to kept compatibility with the new CSSDirector class. @@ -5561,18 +5761,11 @@ var cp1= proxy( /** * Removes all behaviors from an Actor. * @return this - * - * @deprecated */ emptyBehaviorList : function() { this.behaviorList=[]; return this; }, -/* - emptyKeyframesList : function() { - this.keyframesList= []; - }, -*/ /** * Caches a fillStyle in the Actor. * @param style a valid Canvas rendering context fillStyle. @@ -5670,8 +5863,8 @@ var cp1= proxy( * @return this */ setScale : function( sx, sy ) { - //this.setScaleAnchored( sx, sy, this.width/2, this.height/2 ); - this.setScaleAnchored( sx, sy, .5, .5 ); + this.scaleX=sx; + this.scaleY=sy; this.dirty= true; return this; }, @@ -5735,6 +5928,26 @@ var cp1= proxy( return {x: tx, y: ty}; }, + + setGlobalAnchor : function( ax, ay ) { + this.tAnchorX= ax; + this.rotationX= ax; + this.scaleTX= ax; + + this.tAnchorY= ay; + this.rotationY= ay; + this.scaleTY= ay; + + this.dirty= true; + return this; + }, + + setScaleAnchor : function( sax, say ) { + this.scaleTX= sax; + this.scaleTY= say; + this.dirty= true; + return this; + }, /** * Modify the dimensions on an Actor. * The dimension will not affect the local coordinates system in opposition @@ -5758,6 +5971,13 @@ var cp1= proxy( return this; }, + + setRotationAnchor : function( rax, ray ) { + this.rotationX= ray; + this.rotationY= rax; + this.dirty= true; + return this; + }, /** * A helper method for setRotationAnchored. This methods stablishes the center * of rotation to be the center of the Actor. @@ -5766,7 +5986,8 @@ var cp1= proxy( * @return this */ setRotation : function( angle ) { - this.setRotationAnchored( angle, .5, .5 ); //this.width/2, this.height/2 ); + this.rotationAngle= angle; + this.dirty= true; return this; }, /** @@ -5778,8 +5999,8 @@ var cp1= proxy( */ setRotationAnchored : function( angle, rx, ry ) { this.rotationAngle= angle; - this.rotationX= rx?rx:0; - this.rotationY= ry?ry:0; + this.rotationX= rx; + this.rotationY= ry; this.dirty= true; return this; }, @@ -5827,15 +6048,10 @@ var cp1= proxy( * @param x{number} a float indicating Actor's x position * @param y{number} a float indicating Actor's y position * @return this + * + * @deprecated */ setLocation : function( x, y ) { -/* - this.x= x|0; - this.y= y|0; - - this.oldX= x|0; - this.oldY= y|0; -*/ this.x= x; this.y= y; this.oldX= x; @@ -5845,6 +6061,25 @@ var cp1= proxy( return this; }, + + setPosition : function( x,y ) { + return this.setLocation( x,y ); + }, + + setPositionAnchor : function( pax, pay ) { + this.tAnchorX= pax; + this.tAnchorY= pay; + return this; + }, + + setPositionAnchored : function( x,y,pax,pay ) { + this.setLocation( x,y ); + this.tAnchorX= pax; + this.tAnchorY= pay; + return this; + }, + + /** * This method is called by the Director to know whether the actor is on Scene time. * In case it was necessary, this method will notify any life cycle behaviors about @@ -6049,7 +6284,7 @@ var cp1= proxy( * @return null if the point is not inside the Actor. The Actor otherwise. */ findActorAtPosition : function(point) { - if ( !this.mouseEnabled || !this.isInAnimationFrame(this.time) ) { + if ( !this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time) ) { return null; } @@ -6295,7 +6530,7 @@ var cp1= proxy( } // transformation stuff. - this.setModelViewMatrix(director); + this.setModelViewMatrix(); if ( this.dirty || this.wdirty || this.invalid ) { if ( director.dirtyRectsEnabled ) { @@ -6333,7 +6568,7 @@ var cp1= proxy( * * @return this */ - setModelViewMatrix : function(director) { + setModelViewMatrix : function() { var c,s,_m00,_m01,_m10,_m11; var mm0, mm1, mm2, mm3, mm4, mm5; var mm; @@ -6345,13 +6580,13 @@ var cp1= proxy( mm0= 1; mm1= 0; - mm2= mm[2]; + //mm2= mm[2]; mm3= 0; mm4= 1; - mm5= mm[5]; + //mm5= mm[5]; - mm2= this.x; - mm5= this.y; + mm2= this.x - this.tAnchorX * this.width ; + mm5= this.y - this.tAnchorY * this.height; if ( this.rotationAngle ) { @@ -6458,12 +6693,33 @@ var cp1= proxy( if ( this.isAA ) { var m= this.worldModelViewMatrix.matrix; - AABB.x= m[2]; - AABB.y= m[5]; - AABB.x1= m[2] + this.width; - AABB.y1= m[5] + this.height; - AABB.width= AABB.x1-AABB.x; - AABB.height= AABB.y1-AABB.y; + var x= m[2]; + var y= m[5]; + var w= this.width; + var h= this.height; + AABB.x= x; + AABB.y= y; + AABB.x1= x + w; + AABB.y1= y + h; + AABB.width= w; + AABB.height= h; + + if ( CAAT.GLRENDER ) { + var vvv; + vvv= vv[0]; + vvv.x=x; + vvv.y=y; + vvv= vv[1]; + vvv.x=x+w; + vvv.y=y; + vvv= vv[2]; + vvv.x=x+w; + vvv.y=y+h; + vvv= vv[3]; + vvv.x=x; + vvv.y=y+h; + } + return this; } @@ -6571,7 +6827,6 @@ var cp1= proxy( ctx.globalAlpha= this.frameAlpha; director.modelViewMatrix.transformRenderingContextSet( ctx ); - this.worldModelViewMatrix.transformRenderingContext(ctx); if ( this.clip ) { @@ -6977,7 +7232,6 @@ var cp1= proxy( cl[i].drawScreenBoundingBox(director,time); } CAAT.ActorContainer.superclass.drawScreenBoundingBox.call(this,director,time); - }, /** * Removes all children from this ActorContainer. @@ -7173,7 +7427,7 @@ var cp1= proxy( throw('adding to a container an element with parent.'); } - child.setParent(this); // Pour surcharger / polymorphisme de TextArea + child.parent= this; this.childrenList.push(child); child.dirty= true; @@ -7297,6 +7551,11 @@ var cp1= proxy( return this; }, + removeFirstChild : function() { + var first= this.childrenList.shift(); + first.parent= null; + return first; + }, /** * @private * @@ -7560,6 +7819,14 @@ var cp1= proxy( return this; } + if ( this.font instanceof CAAT.SpriteImage ) { + this.textWidth= this.font.stringWidth( this.text ); + this.textHeight=this.font.stringHeight(); + this.width= this.textWidth; + this.height= this.textHeight; + return this; + } + var ctx= director.ctx; ctx.save(); @@ -7617,7 +7884,7 @@ var cp1= proxy( var ctx= director.ctx; - if (typeof this.font === 'object') { + if ( this.font instanceof CAAT.SpriteImage ) { return this.drawSpriteText(director,time); } @@ -7756,7 +8023,7 @@ var cp1= proxy( context.save(); - context.translate( (0.5+p0.x)|0, (0.5+p0.y)|0 ); + context.translate( p0.x|0, p0.y|0 ); context.rotate( angle ); var y = this.textBaseline === "bottom" ? 0 - this.font.height : 0; @@ -7792,7 +8059,7 @@ var cp1= proxy( } }; - extend( CAAT.TextActor, CAAT.ActorContainer, null); + extend( CAAT.TextActor, CAAT.Actor, null); })(); (function() { @@ -9054,19 +9321,6 @@ var cp1= proxy( dirtyRectsEnabled : false, nDirtyRects : 0, - collidingActors : null, - name : "CAAT.Director", - - solveCollissions : function() { - if ( !this.collidingActors.length ) { - return; - } - - - }, - addCollidingActor : function( actor ) { - this.collidingActors.push( actor ); - }, checkDebug : function() { if ( CAAT.DEBUG ) { var dd= new CAAT.Debug().initialize( this.width, 60 ); @@ -9183,7 +9437,10 @@ var cp1= proxy( * @return this */ initialize : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } this.canvas = canvas; if ( typeof proxy==='undefined' ) { @@ -9227,7 +9484,11 @@ var cp1= proxy( */ initializeGL : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } + canvas.width = width; canvas.height = height; @@ -9244,6 +9505,7 @@ var cp1= proxy( this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); this.gl.viewportWidth = width; this.gl.viewportHeight = height; + CAAT.GLRENDER= true; } catch(e) { } @@ -9522,6 +9784,8 @@ var cp1= proxy( ctx.save(); if ( this.dirtyRectsEnabled ) { + this.modelViewMatrix.transformRenderingContext( ctx ); + if ( !CAAT.DEBUG_DIRTYRECTS ) { ctx.beginPath(); this.nDirtyRects=0; @@ -9587,7 +9851,7 @@ var cp1= proxy( } } - if ( CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { + if ( this.nDirtyRects>0 && CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { ctx.beginPath(); this.nDirtyRects=0; var dr= this.cDirtyRects; @@ -9598,11 +9862,10 @@ var cp1= proxy( this.nDirtyRects++; } } - if ( this.nDirtyRects>0 ) { - ctx.clip(); - ctx.fillStyle='rgba(160,255,150,.4)'; - ctx.fillRect(0,0,this.width, this.height); - } + + ctx.clip(); + ctx.fillStyle='rgba(160,255,150,.4)'; + ctx.fillRect(0,0,this.width, this.height); } ctx.restore(); @@ -9620,13 +9883,13 @@ var cp1= proxy( */ animate : function(director, time) { this.setModelViewMatrix(this); + this.modelViewMatrixI= this.modelViewMatrix.getInverse(); this.setScreenBounds(); this.dirty= false; this.invalid= false; this.dirtyRectsIndex= -1; this.cDirtyRects= []; - this.collidingActors= []; var cl= this.childrenList; var cli; @@ -9636,8 +9899,6 @@ var cp1= proxy( cli.animate(this, tt); } - this.solveCollissions(); - return this; }, /** @@ -10327,7 +10588,7 @@ var cp1= proxy( * will have their areas redrawn. * + CAAT.Director.CLEAR_NONE. clears nothing. * - * @param clear {CAAT.Director.CLEAR_ALL |CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} + * @param clear {CAAT.Director.CLEAR_ALL |ÊCAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} * @return this. */ setClear : function(clear) { @@ -10421,7 +10682,9 @@ var cp1= proxy( // transformar coordenada inversamente con affine transform de director. var pt= new CAAT.Point( posx, posy ); - this.modelViewMatrixI= this.modelViewMatrix.getInverse(); + if ( !this.modelViewMatrixI ) { + this.modelViewMatrixI= this.modelViewMatrix.getInverse(); + } this.modelViewMatrixI.transformCoord(pt); posx= pt.x; posy= pt.y @@ -10514,6 +10777,8 @@ var cp1= proxy( var lactor; var pos; + var ct= this.currentScene ? this.currentScene.time : 0; + // drag if (this.isMouseDown && null !== this.lastSelectedActor) { @@ -10545,7 +10810,7 @@ var cp1= proxy( new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y), - this.currentScene.time)); + ct)); this.prevMousePoint.x= pos.x; this.prevMousePoint.y= pos.y; @@ -10565,7 +10830,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = false; } @@ -10577,7 +10842,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = true; } } @@ -10604,7 +10869,7 @@ var cp1= proxy( e, this.lastSelectedActor, this.screenMousePoint, - this.currentScene.time)); + ct)); } if (null !== lactor) { @@ -10618,7 +10883,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } } @@ -10634,7 +10899,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } this.lastSelectedActor = lactor; @@ -10689,7 +10954,7 @@ var cp1= proxy( e, lactor, this.screenMousePoint, - this.currentScene.time); + this.currentScane ? this.currentScene.time : 0); lactor.mouseOver(ev); lactor.mouseEnter(ev); @@ -11001,7 +11266,8 @@ var cp1= proxy( } extend(CAAT.Director, CAAT.ActorContainer, null); -})();/** +})(); +/** * See LICENSE file. * * MouseEvent is a class to hold necessary information of every mouse event related to concrete @@ -11087,6 +11353,8 @@ CAAT.setCoordinateClamping= function( clamp ) { */ CAAT.PMR= 64; +CAAT.GLRENDER= false; + /** * Allow visual debugging artifacts. */ @@ -11171,29 +11439,6 @@ CAAT.registerKeyListener= function(f) { CAAT.keyListeners.push(f); }; -CAAT.registerKeyListenerIfNeeded= function(f) { - for( var i=0; i 0 ) { xoff= xoff-w; } - var yoff= this.offsetY % h; + var yoff= (this.offsetY-this.ownerActor.y) % h; if ( yoff> 0 ) { yoff= yoff-h; } - var nw= (((this.ownerActor.width-xoff)/w)>>0)+1; - var nh= (((this.ownerActor.height-yoff)/h)>>0)+1; + var nw= (((r.width-xoff)/w)>>0)+1; + var nh= (((r.height-yoff)/h)>>0)+1; var i,j; var ctx= director.ctx; for( i=0; i>0, (y+yoff+i*el.height)>>0, + (r.x-this.ownerActor.x+xoff+j*el.width)>>0, (r.y-this.ownerActor.y+yoff+i*el.height)>>0, el.width, el.height); } } @@ -12348,6 +12576,25 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { return w; }, + stringHeight : function() { + if ( this.fontHeight ) { + return this.fontHeight; + } + + var y= 0; + for( var i in this.mapInfo ) { + var mi= this.mapInfo[i]; + + var h= mi.height+mi.yoffset; + if ( h>y ) { + y=h; + } + } + + this.fontHeight= y; + return this.fontHeight; + }, + drawString : function( ctx, str, x, y ) { var i, l, charInfo, w; var charArr = str.split(""); @@ -12368,7 +12615,6 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { } } } - }; @@ -12600,7 +12846,6 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { timerSequence: 0, // incremental CAAT.TimerTask id. paused: false, - name: "CAAT.Scene", isPaused : function() { return this.paused; @@ -13055,6 +13300,122 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) { ctx.fillStyle= this.fillStyle; ctx.fillRect(0,0,this.width,this.height ); } + }, + /** + * Find a pointed actor at position point. + * This method tries lo find the correctly pointed actor in two different ways. + * + first of all, if inputList is defined, it will look for an actor in it. + * + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. + * @param point + */ + findActorAtPosition : function(point) { + var i,j; + + var p= new CAAT.Point(); + + if ( this.inputList ) { + var il= this.inputList; + for( i=0; i number of lists. + */ + enableInputList : function( size ) { + this.inputList= []; + for( var i=0; i an actor instance + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists. + * @param position the position on the selected inputList to add the actor at. This value will be + * clamped to the number of available lists. + */ + addActorToInputList : function( actor, index, position ) { + if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1; + var il= this.inputList[index]; + + if ( typeof position==="undefined" || position>=il.length ) { + il.push( actor ); + } else if (position<=0) { + il.unshift( actor ); + } else { + il.splice( position, 0, actor ); + } + + return this; + }, + + /** + * Remove all elements from an input list. + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists so take care when emptying a non existant inputList index since you could end up emptying + * an undesired input list. + */ + emptyInputList : function( index ) { + if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1; + this.inputList[index]= []; + return this; + }, + + /** + * remove an actor from a given input list index. + * If no index is supplied, the actor will be removed from every input list. + * @param actor + * @param index an optional input list index. This value will be clamped to the number of + * available lists. + */ + removeActorFromInputList : function( actor, index ) { + if ( typeof index==="undefined" ) { + var i,j; + for( i=0; i=this.inputList.length ) index= this.inputList.length-1; + var il= this.inputList[index]; + for( j=0; j, bottom, left }} + * @param !areas { object{ top, bottom, left }Ê} */ CAAT.modules.ImageUtil.optimize= function(image, threshold, areas ) { threshold>>=0; @@ -14013,10 +14374,9 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** var cchar; for( i=0; i>0)+1 ) + 2 * padding ; - var cw= Math.max( 1, (ctx.measureText( chars.charAt(i) ).width>>0)+1 ); + var cw= Math.max( 1, (ctx.measureText( chars.charAt(i) ).width>>0)+1 ) + 2 * padding ; charWidth.push(cw); - textWidth+= cw + 2 * padding; + textWidth+= cw; } canvas.width= textWidth; @@ -14030,19 +14390,19 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.charMap= {}; - x=padding; // x=0 + x=0; for( i=0; i=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + }, /** * Analogously to the method getPosition, this method returns a CAAT.Point instance with @@ -15573,7 +16008,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Indicates that some path control point has changed, and that the path must recalculate * its internal data, ie: length and bbox. */ - updatePath : function(point) { + updatePath : function(point, callback) { var i,j; this.length=0; @@ -15631,6 +16066,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.extractPathPoints(); + if ( typeof callback!=='undefined' ) { + callback(this); + } + return this; }, @@ -15667,7 +16106,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * @param x {number} * @param y {number} */ - drag : function(x,y) { + drag : function(x,y,callback) { if (!this.interactive) { return; } @@ -15687,7 +16126,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.ax= x; this.ay= y; - this.updatePath(this.point); + this.updatePath(this.point,callback); }, /** * Returns a collection of CAAT.Point objects which conform a path's contour. @@ -15839,8 +16278,8 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** mm3= 0; mm4= 1; - mm2= this.tb_x - bbx; - mm5= this.tb_y - bby; + mm2= this.tb_x - bbx - this.tAnchorX * bbw; + mm5= this.tb_y - bby - this.tAnchorY * bbh; if ( this.rb_angle ) { @@ -15900,6 +16339,15 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this; }, + setRotationAnchor : function( ax, ay ) { + this.rb_rotateAnchorX= ax; + this.rb_rotateAnchorY= ay; + }, + + setRotation : function( angle ) { + this.rb_angle= angle; + }, + setScaleAnchored : function( scaleX, scaleY, sx, sy ) { this.sb_scaleX= scaleX; this.sb_scaleAnchorX= sx; @@ -15908,10 +16356,58 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this; }, + setScale : function( sx, sy ) { + this.sb_scaleX= sx; + this.sb_scaleY= sy; + return this; + }, + + setScaleAnchor : function( ax, ay ) { + this.sb_scaleAnchorX= ax; + this.sb_scaleAnchorY= ay; + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= ax; + this.tAnchorY= ay; + return this; + }, + + setPositionAnchored : function( x,y,ax,ay ) { + this.tb_x= x; + this.tb_y= y; + this.tAnchorX= ax; + this.tAnchorY= ay; + return this; + }, + + setPosition : function( x,y ) { + this.tb_x= x; + this.tb_y= y; + return this; + }, + setLocation : function( x, y ) { this.tb_x= x; this.tb_y= y; return this; + }, + + flatten : function( npatches, closed ) { + var point= this.getPositionFromLength(0); + var path= new CAAT.Path().beginPath( point.x, point.y ); + for( var i=0; i 0) { - this.setCursorPos(this.cursorPos -1); - } - }, - - moveRight : function( ) { - if (null!==this.text && this.cursorPos < this.text.length) { - this.setCursorPos(this.cursorPos +1); - } - }, - - delete : function( ) { - if (null!==this.text && this.text.length > 0) { - var newText = this.text.substr(0 , this.cursorPos) + this.text.substr( this.cursorPos +1, this.text.length - this.cursorPos - 1); - this.setText(newText, true); - // cursorPos modified only if last character was deleted - if (this.cursorPos > this.text.length) { - this.setCursorPos(this.text.length); - // this.cursorPos = this.text.length; - } - - } - }, - - backspace : function( ) { - if (this.cursorPos > 0) { - var newText = this.text.substr(0 , this.cursorPos -1) + this.text.substr( this.cursorPos, this.text.length - this.cursorPos); - this.setText(newText, true); - this.setCursorPos(this.cursorPos - 1); - } - }, - - insert : function( newChar ) { - if ( null!== this.text) { - var newText = this.text.substr(0 , this.cursorPos) + newChar + this.text.substr( this.cursorPos, this.text.length - this.cursorPos); - this.setText(newText, true); - } else { - this.setText(newChar, true); - } - this.setCursorPos(this.cursorPos+1); - }, - - setCursorPos : function( pos ) { - console.log("setCursorPos : before " + this.cursorPos); - if ( null=== this.text) { - this.cursorPos = 0; - } else { - if (typeof(pos) === 'undefined' || null ===pos) { - this.cursorPos = this.text.length; - } else { - this.cursorPos = pos; - } - console.log("setCursorPos : after " + this.cursorPos); - cursorPosx = this.font.stringWidth(this.text.substr(0 , this.cursorPos)); - - if (this.cursorActor != null) { - this.cursorActor.setLocation( cursorPosx , 0); - } - } - }, - - - /** - * Set the text to be shown by the actor. - * @param sText a string with the text to be shown. - * @return this - */ - setText : function( sText, keepCursor) { - this.text= sText; - if ( null===this.text || this.text==="" ) { - this.width= this.height= 0; - } - this.calcTextSize( CAAT.director[0] ); - if (typeof(keepCursor) === 'undefined' || !keepCursor) { - this.setCursorPos(); - } - return this; - }, - /** - * Sets the font to be applied for the text. - * @param font a string with a valid canvas rendering context font description. - * @return this - */ - setFont : function(font) { - - if ( !font ) { - this.setDefaultFont(); - } - - this.font= font; - this.calcTextSize( CAAT.director[0] ); - - // Update cursor to the same font - this.setDefaultCursor(); - - return this; - }, - /** - * Calculates the text dimension in pixels and stores the values in textWidth and textHeight - * attributes. - * If Actor's width and height were not set, the Actor's dimension will be set to these values. - * @return this - */ - calcTextSize : function() { - - if ( typeof this.text==='undefined' || null===this.text || ""===this.text ) { - this.textWidth= 0; - this.textHeight= 0; - return this; - } - - // The font provides stringWidth() - - this.textWidth= this.font.stringWidth(this.text); - this.width= this.textWidth; - - - this.lineHeight = this.font.height; - this.textHeight= this.lineHeight; - this.height= this.textHeight; - - return this; - }, - - /** - * Custom paint method for TextArea instances. - * If the path attribute is set, the text will be drawn traversing the path. - * - * @param director a valid CAAT.Director instance. - * @param time an integer with the Scene time the Actor is being drawn. - */ - paint : function(director, time) { - - CAAT.TextArea.superclass.paint.call(this, director, time ); - - // TextArea can be cached (but not editors) - if ( this.cached ) { - // cacheAsBitmap sets this actor's background image as a representation of itself. - // So if after drawing the background it was cached, we're done. - return; - } - - if ( null===this.text) { - return; - } - - if ( this.textWidth===0 || this.textHeight===0 ) { - this.calcTextSize(director); - } - - var ctx= director.ctx; - - // Is drawing on path useful here ? - if (typeof this.font === 'object') { - return this.drawSpriteText(director,time); - } - }, - - // Ou peut on conserver les méthodes héritées de TextActor? - - /** - * Private. - * Draw the text using a sprited font instead of a canvas font. - * @param director a valid CAAT.Director instance. - * @param time an integer with the Scene time the Actor is being drawn. - */ - drawSpriteText: function(director, time) { - this.font.drawString( director.ctx, this.text, 0, 0); - } - }; - - extend( CAAT.TextArea, CAAT.ActorContainer, null); -})(); - - -(function() { - - /** - * TextInputGroup - * Invisible Container managing the focus of a set of TextAreas - * childrenList order is used for navigation - * focus can also be set programatically - - * @constructor - * @extends CAAT.ActorContainer - * - */ - CAAT.TextInputGroup = function() { - CAAT.TextInputGroup.superclass.constructor.call(this); - - // A singleton is created to store a map between scenes and input groups - if (typeof(CAAT.TextInputGroup.SceneFocusManager) === 'undefined' ) { - CAAT.TextInputGroup.SceneFocusManager = {};// dictionnaire Scene -> TextInputGroup - } - - return this; - }; - - - CAAT.TextInputGroup.prototype= { - focusedChild: null, - focusedChildIndex: null, // position in childrenList of ActorContainer - - setParent : function(parent) { - CAAT.TextInputGroup.superclass.setParent.call(this, parent); - return this; - }, - - deferredInit: function(director) { - var sceneIndex = director.getSceneIndex(this.getScene()); // A tester - - // Associate Scene -> TextInputGroup - CAAT.TextInputGroup.SceneFocusManager[sceneIndex] = this; - - // Key event callback must be defined only once, otherwise key events will be duplicated - CAAT.registerKeyListenerIfNeeded(this.___keyAction.bind(this)); - }, - - - ___keyAction: function(event) { - // Events are discarded if the scene is not current one - if (CAAT.director[0].currentScene != this.getScene()) { return; } - - var inputText = this.getFocused(); - if (typeof(inputText) === 'undefined' || typeof(inputText) === 'undefined' || null ===inputText) return; - - if (event.getAction()=='down') { - // event.preventDefault(); - //console.log("text = " + CAAT.TextArea.focus.text); - switch (event.getKeyCode()) { - case CAAT.Keys['DELETE']: - // The empty text case has already been excluded above - inputText.delete(); - event.preventDefault(); - break; - case CAAT.Keys['BACKSPACE']: - // The empty text case has already been excluded above - inputText.backspace(); - event.preventDefault(); - break; - case CAAT.Keys['LEFT']: - inputText.moveLeft(); - event.preventDefault(); - break; - case CAAT.Keys['RIGHT']: - inputText.moveRight(); - event.preventDefault(); - break; - case CAAT.Keys['UP']: - case CAAT.Keys['DOWN']: - // LATER ? - event.preventDefault(); - break; - case CAAT.Keys['TAB']: - if (event.isShiftPressed()) { - this.prevChild(); - } else { - this.nextChild(); - } - event.preventDefault(); - break; - default: - // other keys handled as keypress events - // event.preventDefault(); is not called as it would cancel the keypress event - break; - } - - } - if (event.getAction()=='press') { - - switch (event.getKeyCode()) { - case CAAT.Keys['DELETE']: - case CAAT.Keys['BACKSPACE']: - break; - case CAAT.Keys['LEFT']: - - break; - case CAAT.Keys['RIGHT']: - - break; - default: - var newChar = String.fromCharCode(event.getKeyCode()); - inputText.insert(newChar); - - break; - } - - } - - }, - - getFocused: function() { - return this.focusedChild; - }, - - - prevChild: function() { - if (this.focusedChildIndex > 0) { - - this.notifyFocusLost(this.focusedChild); - - this.focusedChildIndex--; - this.focusedChild = this.childrenList[this.focusedChildIndex]; - - this.notifyFocus(this.focusedChild); - } - }, - - nextChild: function() { - var newFocusedChildIndex = null; - - if (this.focusedChildIndex < this.childrenList.length -1) { - newFocusedChildIndex = this.focusedChildIndex+1; - newFocusedChild = this.childrenList[this.focusedChildIndex++]; - - } else { - if (this.focusedChildIndex === this.childrenList.length -1) { - newFocusedChildIndex = 0; - newFocusedChild = this.childrenList[newFocusedChildIndex]; - } - } - - if (newFocusedChildIndex !=null) { - this.notifyFocusLost(this.focusedChild); - - this.focusedChildIndex = newFocusedChildIndex; - this.focusedChild = this.childrenList[newFocusedChildIndex]; - - this.notifyFocus(this.focusedChild); - } - }, - /** - * Removes all children from this ActorContainer. - * - * @return this - */ - emptyChildren : function() { - CAAT.TextInputGroup.superclass.emptyChildren.call(this); - - // notify previously focused Child of lost of focus ? - // The actor will not be shown anymore ?? - this.notifyFocusLost(this.focusedChild); - - this.focusedChild= null; - this.focusedChildIndex = null; - - return this; - }, - /** - * Adds an Actor to this ActorContainer. - - * @param child a CAAT.Actor object instance. - * @return this - */ - addChild : function(child) { - - CAAT.TextInputGroup.superclass.addChild.call(this, child); - - // Focus it only if it is the first child - this.setFocusToFirstChildOnly(child); - - return this; - }, - - setFocusToFirstChildOnly : function(child) { - // set focus only if it is the first child added - if (this.focusedChild === null) { - this.focusedChildIndex = 0; - this.focusedChild = child; - this.notifyFocus(this.focusedChild); - } - }, - - /** - * Adds an Actor to this ActorContainer. - * - * @param child a CAAT.Actor object instance. - * - * @return this - */ - addChildAt : function(child, index) { - - CAAT.TextInputGroup.superclass.addChildAt.call(this, child, index); - - // No change in focus in the general case - this.setFocusToFirstChildOnly(child); - - return this; - }, - - /** - * Removed an Actor form this ActorContainer. - * If the Actor is not contained into this Container, nothing happends. - * - * @param child a CAAT.Actor object instance. - * - * @return this - */ - removeChild : function(child) { - - CAAT.TextInputGroup.superclass.removeChild.call(this, child); - - // If the child had focus, update the state - if (this.focusedChild === child) { - this.focusedChild = null; - this.focusedChildIndex = null; - this.notifyFocusLost(child); - } - - return this; - }, - - /** - * Sets the font to be applied for the text. - * @param font a string with a valid canvas rendering context font description. - * @return this - */ - focusChild : function(child) { - var childIndex = this.childrenList.indexOf(child); - - if (childIndex != -1) { - - if (this.focusedChild != null) { - this.notifyFocusLost(this.focusedChild); - } - - this.focusedChild = child; - this.focusedChildIndex = childIndex; - this.notifyFocus(child); - } - - return this; - }, - - notifyFocus : function(child) { - child.onFocus(); - }, - - - notifyFocusLost : function(child) { - if (child != null) { - child.onFocusLost(); - } - } - - - - - }; - - extend( CAAT.TextInputGroup, CAAT.ActorContainer, null); -})(); - +})(); \ No newline at end of file diff --git a/changelog b/changelog index 30c6655f..61761db6 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,49 @@ +02/23/2012 *0.3 Build 212* +-------------------------- + +* Added to CAAT.Scene the following methods: + + findActorAtPosition(CAAT.Point) : custom actor find procedure. This is overriden to attend at the priority input lists. + + enableInputList(number) : number of priority lists to set for this scene. A priority list is a list of actors to + which are suitable to receive input first. If no actor on the priority lists are under + the cursor, the whole scene graph is traversed instead. + + addActorToInputList( actor, index, position ) : add an actor to a given priority list at certain position. + + emptyInputList( index ) : remove all elements from a list. + + removeActorFromInputList( actor, index ) : remove an actor from a list, or if no index list is supplied remove + the actor from every list in which appears. +* Fixed Actor.setImageTransformation( CAAT.SpriteImage.prototype.TR_TILE ) which didn't honor actor position and offset + to appropriately place the tiling image. Also the performance sink when using this flag with huge actors's been fixed. +* Fixed an issue when entering scene gets mouse input. + +02/21/2012 *0.3 Build 180* +-------------------------- + +* Fixed (at last) Catmull Rom splines as CAAT.Path objects. +* Added CAAT.Path.flatten method to turn a compound path of patches into a polyline. +* Added CAAT.PathActor.setOnUpdateCallback + +02/10/2012 *0.3 Build 138* +-------------------------- + +* Deprecated CAAT.PathBehavior.setTranslation function in favor of CAAT.Actor.setPositionAnchor function. +* Deprecated method setLocation in favor of setPosition. +* Added translation anchor. setpositionAnchor, setPosition. +* Added methods setRotationAnchor, setScaleAnchor, setGlobalAnchor to CAAT.Actor. +* Fixed bug with dirty rects and scaled canvas. It wasn't repainting the correct screen areas. +* Added CAAT.SpatialHash object. +* Added Behavior.setDelayTime( delay, duration ). This method applies the behavior after delay ms from current scene time + so there's no need to know currentScene time to set a behavior anymore. +* Added CAAT.SpriteImage.stringHeight method which gives the highest char height on the sprite image atlas map. +* Fixed CAAT.ContainerBehavior that on expiration notified twice behavior expiration event (one from base class, and another + one from the container itself). +* Fixed CAAT.TextActor issue when drawing text with CAAT.SpriteImage +* Clip Paths also honors the new method setPositionAnchor in CAAT.Actor. Added methods setRotationAnchor, setRotation, + setScaleAnchor, setScale, setPosition, setPositionAnchor to CAAT.Path. +* Added global flag CAAT.GLRENDER. + 02/09/2012 *0.3 Build 64* -------------------------- -* Fixed setScreenBounds method which was calculating the bounding box erroneusly when in negative coords. +* Fixed setScreenBounds method which was calculating the bounding box erroneously when in negative coordinates. Note to self: Number.MIN_VALUE != -Number.MAX_VALUE !!!!. * Fixed the case where a path composed by one single segment with overlapping starting and ending point was returning (0,0) as path traversal. Now returns one of the two overlapping points. @@ -31,7 +73,7 @@ * Removed some non ansi characters from sourcecode comments. * Added setGestureEnabled and isGestureEnabled methods to CAAT.Actor on CSS renderer. * TextActor recalculates its size when font or text is changed. -* Added DirtyRects info to Debug panel. Number of rects, and on-screen representation. +* Added DirtyRects info to Debug panel. Number of rectangles, and on-screen representation. 01/26/2012 *0.2 Build 52* -------------------------- diff --git a/documentation/demos/demo-resources/img/hoppy.png b/documentation/demos/demo-resources/img/hoppy.png new file mode 100644 index 00000000..a0195f1e Binary files /dev/null and b/documentation/demos/demo-resources/img/hoppy.png differ diff --git a/documentation/demos/demo-resources/img/numerospuntos.png b/documentation/demos/demo-resources/img/numerospuntos.png new file mode 100644 index 00000000..4aaf3750 Binary files /dev/null and b/documentation/demos/demo-resources/img/numerospuntos.png differ diff --git a/documentation/demos/demo1/path_org.html b/documentation/demos/demo1/path_org.html index 94143b7f..c532cd01 100644 --- a/documentation/demos/demo1/path_org.html +++ b/documentation/demos/demo1/path_org.html @@ -54,6 +54,7 @@

Path management

  • Constructing a Path and adding segments to it.
  • +
  • Setting positional anchors.
  • What does a call to closePath means in opposition to endPath.
  • Showing a path by associating it to a PathActor.
  • Path management by calling setInteractive method.
  • @@ -106,6 +107,7 @@

    Path management

    * Startup it all up when the document is ready. * Change for your favorite frameworks initialization code. */ + CAAT.DEBUG=1; window.addEventListener( 'load', function() { @@ -113,7 +115,8 @@

    Path management

    800, 500, 'experiment-holder', [ - {id:'fish', url:'../demo-resources/img/anim2.png'} + {id:'fish', url:'../demo-resources/img/anim2.png'}, + {id:'score', url: "../demo-resources/img/numerospuntos.png"} ], __scene1 ); @@ -207,20 +210,60 @@

    Path management

    var scene = director.createScene(); + var dw= director.width; + var dh= director.height; + + + var i; + var R= (Math.min( dw,dh ) - 40)/2; + var pp= []; + var angle; + var NP=7; + for( i=0; iPath management true). setAnimationImageIndex([0,1,2,1]). setChangeFPS(300). - enableEvents(false); + enableEvents(false). + setId(111); + + fish.setPositionAnchor(.5, .5); // path measurer behaviour var pb = new CAAT.PathBehavior(). setPath(path). setFrameTime(0, 20000). setCycle(true). - setAutoRotate(true, CAAT.PathBehavior.autorotate.LEFT_TO_RIGHT). - setTranslation(fish.width / 2, fish.height / 2); + setAutoRotate(true, CAAT.PathBehavior.autorotate.LEFT_TO_RIGHT); fish.addBehavior(pb); @@ -256,9 +301,9 @@

    Path management

    function addDescription(director, scene) { var cc1 = new CAAT.ActorContainer(). - setBounds(0, 30, 280, 110). - create(). + setBounds(140, 80, 280, 110). enableEvents(false); + cc1.setPositionAnchor(.5,.5); scene.addChild(cc1); cc1.addBehavior( @@ -282,7 +327,7 @@

    Path management

    setTextFillStyle(gradient). setOutline(true). cacheAsBitmap(); - cc1.addChild(text.setLocation((cc1.width - text.textWidth) / 2, 0)); + cc1.addChild(text.setLocation((cc1.width - text.textWidth) / 2, 0) ); var text2 = new CAAT.TextActor(). setFont("20px sans-serif"). diff --git a/documentation/demos/demo16/mask_org.html b/documentation/demos/demo16/mask_org.html index 4506e4f8..a03c5d23 100644 --- a/documentation/demos/demo16/mask_org.html +++ b/documentation/demos/demo16/mask_org.html @@ -160,12 +160,14 @@

    Masking with arbitrary paths

    director.width - 100, director.height - 10, 100, director.height - 10, 100, director.height / 2). - closePath(), + closePath(). + setPositionAnchor(.5,.5), new CAAT.Path(). beginPath(100,100). addRectangleTo( director.width-100, director.height-100 ). - endPath(), + endPath(). + setPositionAnchor(.5,.5), new CAAT.Path(). beginPath(200,200). @@ -174,7 +176,8 @@

    Masking with arbitrary paths

    addQuadricTo( 400,400, 350,200 ). addCubicTo( 100,300, 300,450, 10,400). addQuadricTo( 40,200, 200,200 ). - closePath() + closePath(). + setPositionAnchor(.5,.5) ]; @@ -184,7 +187,6 @@

    Masking with arbitrary paths

    setValues( path2 ). setFrameTime( 0,15000 ). setCycle( true ) - .setTranslation( path[i].width/2, path[i].height/2 ) ).addBehavior( new CAAT.RotateBehavior(). setValues( 0,Math.PI*2, .5, .5 ). @@ -208,6 +210,7 @@

    Masking with arbitrary paths

    gr.mouseClick= function(e) { pathIndex++; gr.setClip( true, path[ pathIndex%path.length ] ); + } } diff --git a/documentation/demos/demo18/keys_org.html b/documentation/demos/demo18/keys_org.html index 5e0381f6..8c2e214a 100644 --- a/documentation/demos/demo18/keys_org.html +++ b/documentation/demos/demo18/keys_org.html @@ -224,7 +224,7 @@

    Keyboard management

    - +