diff --git a/AUTHORS b/AUTHORS index 31e56d4c..a62c1dbd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,5 +4,6 @@ src/lib/Box2dWeb-2.1.a.3.js: Erin Catto http://www.gphysics.com Thanks: - Mario Gonzalez [@onedayitwillmake] + Mario Gonzalez [@onedayitwillmake] + Rob Boerman [@robboerman] diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index b6ccef18..0f02289d 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.2 build: 33 +Version: 0.2 build: 37 Created on: DATE: 2012-01-23 -TIME: 18:05:44 +TIME: 23:04:06 */ diff --git a/build/caat-box2d.js b/build/caat-box2d.js index 235dba9e..b63d0e5e 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.2 build: 34 +Version: 0.2 build: 38 Created on: DATE: 2012-01-23 -TIME: 18:06:09 +TIME: 23:04:32 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index 19d9c78a..d15628bb 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.2 build: 33 +Version: 0.2 build: 37 Created on: DATE: 2012-01-23 -TIME: 18:05:44 +TIME: 23:04:06 */ -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;CAAT.__CSS__=1;CAAT.__CSS__=1;CAAT.__CSS__=1;CAAT.__CSS__=1;CAAT.__CSS__=1;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=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=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;b=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;b=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=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;b=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;b/User
- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
\ No newline at end of file diff --git a/documentation/jsdoc/index.html b/documentation/jsdoc/index.html index 34aae5a9..791ec31c 100644 --- a/documentation/jsdoc/index.html +++ b/documentation/jsdoc/index.html @@ -564,7 +564,7 @@

Function

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
\ No newline at end of file diff --git a/documentation/jsdoc/symbols/CAAT.Actor.html b/documentation/jsdoc/symbols/CAAT.Actor.html index c25b0181..2c48c4f4 100644 --- a/documentation/jsdoc/symbols/CAAT.Actor.html +++ b/documentation/jsdoc/symbols/CAAT.Actor.html @@ -4570,7 +4570,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:56 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ActorContainer.html b/documentation/jsdoc/symbols/CAAT.ActorContainer.html index 3f131be1..2d61cd5c 100644 --- a/documentation/jsdoc/symbols/CAAT.ActorContainer.html +++ b/documentation/jsdoc/symbols/CAAT.ActorContainer.html @@ -1418,7 +1418,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.AudioManager.html b/documentation/jsdoc/symbols/CAAT.AudioManager.html index 2bf019be..4e5b6399 100644 --- a/documentation/jsdoc/symbols/CAAT.AudioManager.html +++ b/documentation/jsdoc/symbols/CAAT.AudioManager.html @@ -1127,7 +1127,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html index db347ae5..bcbade88 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html +++ b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html @@ -1227,7 +1227,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html index aa936ead..10154667 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html @@ -632,7 +632,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html index a2f9e376..3c6fa682 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html @@ -714,7 +714,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Bezier.html b/documentation/jsdoc/symbols/CAAT.Bezier.html index cdf986f6..7603abc6 100644 --- a/documentation/jsdoc/symbols/CAAT.Bezier.html +++ b/documentation/jsdoc/symbols/CAAT.Bezier.html @@ -1022,7 +1022,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CatmullRom.html b/documentation/jsdoc/symbols/CAAT.CatmullRom.html index ad37b50c..aef0c251 100644 --- a/documentation/jsdoc/symbols/CAAT.CatmullRom.html +++ b/documentation/jsdoc/symbols/CAAT.CatmullRom.html @@ -597,7 +597,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.RGB.html b/documentation/jsdoc/symbols/CAAT.Color.RGB.html index 92b70fcd..a104d13b 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.RGB.html +++ b/documentation/jsdoc/symbols/CAAT.Color.RGB.html @@ -470,7 +470,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.html b/documentation/jsdoc/symbols/CAAT.Color.html index ed5f4b11..911b2eb9 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.html +++ b/documentation/jsdoc/symbols/CAAT.Color.html @@ -694,7 +694,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Curve.html b/documentation/jsdoc/symbols/CAAT.Curve.html index 1ed2bb5e..d15124c5 100644 --- a/documentation/jsdoc/symbols/CAAT.Curve.html +++ b/documentation/jsdoc/symbols/CAAT.Curve.html @@ -969,7 +969,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CurvePath.html b/documentation/jsdoc/symbols/CAAT.CurvePath.html index 783bc270..228b39d6 100644 --- a/documentation/jsdoc/symbols/CAAT.CurvePath.html +++ b/documentation/jsdoc/symbols/CAAT.CurvePath.html @@ -1205,7 +1205,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:06 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:57 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Director.html b/documentation/jsdoc/symbols/CAAT.Director.html index 638ea576..b811a9e2 100644 --- a/documentation/jsdoc/symbols/CAAT.Director.html +++ b/documentation/jsdoc/symbols/CAAT.Director.html @@ -4425,7 +4425,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Font.html b/documentation/jsdoc/symbols/CAAT.Font.html index bf5ea93d..2fb91211 100644 --- a/documentation/jsdoc/symbols/CAAT.Font.html +++ b/documentation/jsdoc/symbols/CAAT.Font.html @@ -914,7 +914,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMActor.html b/documentation/jsdoc/symbols/CAAT.IMActor.html index 71f6f17b..47adb51f 100644 --- a/documentation/jsdoc/symbols/CAAT.IMActor.html +++ b/documentation/jsdoc/symbols/CAAT.IMActor.html @@ -553,7 +553,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMBump.html b/documentation/jsdoc/symbols/CAAT.IMBump.html index 5372a2ae..d4b98068 100644 --- a/documentation/jsdoc/symbols/CAAT.IMBump.html +++ b/documentation/jsdoc/symbols/CAAT.IMBump.html @@ -819,7 +819,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMPlasma.html b/documentation/jsdoc/symbols/CAAT.IMPlasma.html index b02b6444..c62fd1ce 100644 --- a/documentation/jsdoc/symbols/CAAT.IMPlasma.html +++ b/documentation/jsdoc/symbols/CAAT.IMPlasma.html @@ -574,7 +574,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html index 5ab7c789..d866d512 100644 --- a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html +++ b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html @@ -620,7 +620,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html index a5cd6f38..3d283a46 100644 --- a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html +++ b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html @@ -476,7 +476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html index 35f4368b..874dbb4c 100644 --- a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html +++ b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html @@ -960,7 +960,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Interpolator.html b/documentation/jsdoc/symbols/CAAT.Interpolator.html index 113e9961..bc3ba846 100644 --- a/documentation/jsdoc/symbols/CAAT.Interpolator.html +++ b/documentation/jsdoc/symbols/CAAT.Interpolator.html @@ -1355,7 +1355,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:07 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html index dece0cc1..358f2170 100644 --- a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html +++ b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html @@ -615,7 +615,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.KeyEvent.html b/documentation/jsdoc/symbols/CAAT.KeyEvent.html index 6eedfba2..6df40881 100644 --- a/documentation/jsdoc/symbols/CAAT.KeyEvent.html +++ b/documentation/jsdoc/symbols/CAAT.KeyEvent.html @@ -707,7 +707,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.LinearPath.html b/documentation/jsdoc/symbols/CAAT.LinearPath.html index d85fca74..076b4dec 100644 --- a/documentation/jsdoc/symbols/CAAT.LinearPath.html +++ b/documentation/jsdoc/symbols/CAAT.LinearPath.html @@ -1079,7 +1079,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Matrix3.html b/documentation/jsdoc/symbols/CAAT.Matrix3.html index c1e7dbb6..7c2efccf 100644 --- a/documentation/jsdoc/symbols/CAAT.Matrix3.html +++ b/documentation/jsdoc/symbols/CAAT.Matrix3.html @@ -1615,7 +1615,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MatrixStack.html b/documentation/jsdoc/symbols/CAAT.MatrixStack.html index ea55b538..93c7213f 100644 --- a/documentation/jsdoc/symbols/CAAT.MatrixStack.html +++ b/documentation/jsdoc/symbols/CAAT.MatrixStack.html @@ -624,7 +624,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MouseEvent.html b/documentation/jsdoc/symbols/CAAT.MouseEvent.html index 70cd52f3..fac685b7 100644 --- a/documentation/jsdoc/symbols/CAAT.MouseEvent.html +++ b/documentation/jsdoc/symbols/CAAT.MouseEvent.html @@ -651,7 +651,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Path.html b/documentation/jsdoc/symbols/CAAT.Path.html index b05d74c9..6dea2771 100644 --- a/documentation/jsdoc/symbols/CAAT.Path.html +++ b/documentation/jsdoc/symbols/CAAT.Path.html @@ -2981,7 +2981,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathActor.html b/documentation/jsdoc/symbols/CAAT.PathActor.html index 1d4cfb13..1b950b3f 100644 --- a/documentation/jsdoc/symbols/CAAT.PathActor.html +++ b/documentation/jsdoc/symbols/CAAT.PathActor.html @@ -788,7 +788,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathSegment.html b/documentation/jsdoc/symbols/CAAT.PathSegment.html index a28c7545..d40b4be2 100644 --- a/documentation/jsdoc/symbols/CAAT.PathSegment.html +++ b/documentation/jsdoc/symbols/CAAT.PathSegment.html @@ -1147,7 +1147,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Point.html b/documentation/jsdoc/symbols/CAAT.Point.html index 5129fc8d..80232e30 100644 --- a/documentation/jsdoc/symbols/CAAT.Point.html +++ b/documentation/jsdoc/symbols/CAAT.Point.html @@ -1271,7 +1271,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Rectangle.html b/documentation/jsdoc/symbols/CAAT.Rectangle.html index f63e105e..c2c37866 100644 --- a/documentation/jsdoc/symbols/CAAT.Rectangle.html +++ b/documentation/jsdoc/symbols/CAAT.Rectangle.html @@ -845,7 +845,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Scene.html b/documentation/jsdoc/symbols/CAAT.Scene.html index 8d9a0097..3988fe2a 100644 --- a/documentation/jsdoc/symbols/CAAT.Scene.html +++ b/documentation/jsdoc/symbols/CAAT.Scene.html @@ -1748,7 +1748,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ShapeActor.html b/documentation/jsdoc/symbols/CAAT.ShapeActor.html index a4fa78ff..d2f77113 100644 --- a/documentation/jsdoc/symbols/CAAT.ShapeActor.html +++ b/documentation/jsdoc/symbols/CAAT.ShapeActor.html @@ -990,7 +990,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.SpriteImage.html b/documentation/jsdoc/symbols/CAAT.SpriteImage.html index ecd4ecb8..a1d4ed46 100644 --- a/documentation/jsdoc/symbols/CAAT.SpriteImage.html +++ b/documentation/jsdoc/symbols/CAAT.SpriteImage.html @@ -1899,7 +1899,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.StarActor.html b/documentation/jsdoc/symbols/CAAT.StarActor.html index 05aa4b67..46ccf416 100644 --- a/documentation/jsdoc/symbols/CAAT.StarActor.html +++ b/documentation/jsdoc/symbols/CAAT.StarActor.html @@ -1032,7 +1032,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TextActor.html b/documentation/jsdoc/symbols/CAAT.TextActor.html index 2bae5cb6..38495bf2 100644 --- a/documentation/jsdoc/symbols/CAAT.TextActor.html +++ b/documentation/jsdoc/symbols/CAAT.TextActor.html @@ -1123,7 +1123,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TimerTask.html b/documentation/jsdoc/symbols/CAAT.TimerTask.html index 296070aa..3a13e6cf 100644 --- a/documentation/jsdoc/symbols/CAAT.TimerTask.html +++ b/documentation/jsdoc/symbols/CAAT.TimerTask.html @@ -646,7 +646,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.html b/documentation/jsdoc/symbols/CAAT.html index 18d30769..f5095152 100644 --- a/documentation/jsdoc/symbols/CAAT.html +++ b/documentation/jsdoc/symbols/CAAT.html @@ -1875,7 +1875,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:05 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:56 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html index 7a788a52..5b335576 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html @@ -1025,7 +1025,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html index 7a650b73..d2048339 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html @@ -1054,7 +1054,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html index 31c5fed0..97fd5955 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html @@ -383,7 +383,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html index 9c77844f..509ea58d 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html +++ b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html @@ -568,7 +568,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:59 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.html b/documentation/jsdoc/symbols/CAAT.modules.html index 647e58a3..d8531219 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.html +++ b/documentation/jsdoc/symbols/CAAT.modules.html @@ -476,7 +476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:08 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:58 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/Function.html b/documentation/jsdoc/symbols/Function.html index 2a273771..8b4442f8 100644 --- a/documentation/jsdoc/symbols/Function.html +++ b/documentation/jsdoc/symbols/Function.html @@ -392,7 +392,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:09 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:05:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/_global_.html b/documentation/jsdoc/symbols/_global_.html index a329f0f3..3cd98957 100644 --- a/documentation/jsdoc/symbols/_global_.html +++ b/documentation/jsdoc/symbols/_global_.html @@ -712,7 +712,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jan 22 2012 18:11:05 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jan 23 2012 23:04:56 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html index 0ee9994f..08d35f6c 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html @@ -1141,123 +1141,123 @@ 1134 1135 this.inFrame= true; 1136 -1137 return true; -1138 }, -1139 /** -1140 * Set this model view matrix if the actor is Dirty. -1141 * -1142 mm[2]+= this.x; -1143 mm[5]+= this.y; -1144 if ( this.rotationAngle ) { -1145 this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) ); -1146 this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) ); -1147 this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle ); -1148 } -1149 if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) { -1150 this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) ); -1151 this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) ); -1152 this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) ); -1153 } -1154 * -1155 * @return this -1156 */ -1157 setModelViewMatrix : function(director) { -1158 var c,s,_m00,_m01,_m10,_m11; -1159 var mm0, mm1, mm2, mm3, mm4, mm5; -1160 var mm; -1161 -1162 this.wdirty= false; +1137 +1138 +1139 return true; +1140 }, +1141 /** +1142 * Set this model view matrix if the actor is Dirty. +1143 * +1144 mm[2]+= this.x; +1145 mm[5]+= this.y; +1146 if ( this.rotationAngle ) { +1147 this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) ); +1148 this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) ); +1149 this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle ); +1150 } +1151 if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) { +1152 this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) ); +1153 this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) ); +1154 this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) ); +1155 } +1156 * +1157 * @return this +1158 */ +1159 setModelViewMatrix : function(director) { +1160 var c,s,_m00,_m01,_m10,_m11; +1161 var mm0, mm1, mm2, mm3, mm4, mm5; +1162 var mm; 1163 -1164 if ( this.dirty ) { +1164 this.wdirty= false; 1165 -1166 mm= this.modelViewMatrix.matrix; +1166 if ( this.dirty ) { 1167 -1168 mm0= 1; -1169 mm1= 0; -1170 mm2= mm[2]; -1171 mm3= 0; -1172 mm4= 1; -1173 mm5= mm[5]; -1174 -1175 mm2= this.x; -1176 mm5= this.y; -1177 -1178 if ( this.rotationAngle ) { +1168 mm= this.modelViewMatrix.matrix; +1169 +1170 mm0= 1; +1171 mm1= 0; +1172 mm2= mm[2]; +1173 mm3= 0; +1174 mm4= 1; +1175 mm5= mm[5]; +1176 +1177 mm2= this.x; +1178 mm5= this.y; 1179 -1180 var rx= this.rotationX*this.width; -1181 var ry= this.rotationY*this.height; -1182 -1183 mm2+= mm0*rx + mm1*ry; -1184 mm5+= mm3*rx + mm4*ry; -1185 -1186 c= Math.cos( this.rotationAngle ); -1187 s= Math.sin( this.rotationAngle ); -1188 _m00= mm0; -1189 _m01= mm1; -1190 _m10= mm3; -1191 _m11= mm4; -1192 mm0= _m00*c + _m01*s; -1193 mm1= -_m00*s + _m01*c; -1194 mm3= _m10*c + _m11*s; -1195 mm4= -_m10*s + _m11*c; -1196 -1197 mm2+= -mm0*rx - mm1*ry; -1198 mm5+= -mm3*rx - mm4*ry; -1199 } -1200 if ( this.scaleX!=1 || this.scaleY!=1 ) { -1201 -1202 var sx= this.scaleTX*this.width; -1203 var sy= this.scaleTY*this.height; -1204 -1205 mm2+= mm0*sx + mm1*sy; -1206 mm5+= mm3*sx + mm4*sy; -1207 -1208 mm0= mm0*this.scaleX; -1209 mm1= mm1*this.scaleY; -1210 mm3= mm3*this.scaleX; -1211 mm4= mm4*this.scaleY; -1212 -1213 mm2+= -mm0*sx - mm1*sy; -1214 mm5+= -mm3*sx - mm4*sy; -1215 } -1216 -1217 mm[0]= mm0; -1218 mm[1]= mm1; -1219 mm[2]= mm2; -1220 mm[3]= mm3; -1221 mm[4]= mm4; -1222 mm[5]= mm5; -1223 } -1224 -1225 if ( this.parent ) { -1226 if ( this.dirty || this.parent.wdirty ) { -1227 this.worldModelViewMatrix.copy( this.parent.worldModelViewMatrix ); -1228 this.worldModelViewMatrix.multiply( this.modelViewMatrix ); -1229 this.wdirty= true; -1230 } -1231 } else { -1232 if ( this.dirty ) { -1233 this.wdirty= true; -1234 } -1235 -1236 this.worldModelViewMatrix.identity(); -1237 } -1238 -1239 //if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) { -1240 // screen bounding boxes will always be calculated. -1241 if ( this.dirty || this.wdirty || this.invalid ) { -1242 if ( director.dirtyRectsEnabled ) { -1243 director.addDirtyRect( this.AABB ); -1244 } -1245 this.setScreenBounds(); -1246 if ( director.dirtyRectsEnabled ) { -1247 director.addDirtyRect( this.AABB ); -1248 } -1249 } -1250 this.dirty= false; -1251 this.invalid= false; -1252 -1253 return this; +1180 if ( this.rotationAngle ) { +1181 +1182 var rx= this.rotationX*this.width; +1183 var ry= this.rotationY*this.height; +1184 +1185 mm2+= mm0*rx + mm1*ry; +1186 mm5+= mm3*rx + mm4*ry; +1187 +1188 c= Math.cos( this.rotationAngle ); +1189 s= Math.sin( this.rotationAngle ); +1190 _m00= mm0; +1191 _m01= mm1; +1192 _m10= mm3; +1193 _m11= mm4; +1194 mm0= _m00*c + _m01*s; +1195 mm1= -_m00*s + _m01*c; +1196 mm3= _m10*c + _m11*s; +1197 mm4= -_m10*s + _m11*c; +1198 +1199 mm2+= -mm0*rx - mm1*ry; +1200 mm5+= -mm3*rx - mm4*ry; +1201 } +1202 if ( this.scaleX!=1 || this.scaleY!=1 ) { +1203 +1204 var sx= this.scaleTX*this.width; +1205 var sy= this.scaleTY*this.height; +1206 +1207 mm2+= mm0*sx + mm1*sy; +1208 mm5+= mm3*sx + mm4*sy; +1209 +1210 mm0= mm0*this.scaleX; +1211 mm1= mm1*this.scaleY; +1212 mm3= mm3*this.scaleX; +1213 mm4= mm4*this.scaleY; +1214 +1215 mm2+= -mm0*sx - mm1*sy; +1216 mm5+= -mm3*sx - mm4*sy; +1217 } +1218 +1219 mm[0]= mm0; +1220 mm[1]= mm1; +1221 mm[2]= mm2; +1222 mm[3]= mm3; +1223 mm[4]= mm4; +1224 mm[5]= mm5; +1225 } +1226 +1227 if ( this.parent ) { +1228 if ( this.dirty || this.parent.wdirty ) { +1229 this.worldModelViewMatrix.copy( this.parent.worldModelViewMatrix ); +1230 this.worldModelViewMatrix.multiply( this.modelViewMatrix ); +1231 this.wdirty= true; +1232 } +1233 } else { +1234 if ( this.dirty ) { +1235 this.wdirty= true; +1236 } +1237 +1238 this.worldModelViewMatrix.identity(); +1239 } +1240 +1241 //if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) { +1242 // screen bounding boxes will always be calculated. +1243 if ( this.dirty || this.wdirty || this.invalid ) { +1244 if ( director.dirtyRectsEnabled ) { +1245 director.addDirtyRect( this.AABB ); +1246 } +1247 this.setScreenBounds(); +1248 if ( director.dirtyRectsEnabled ) { +1249 director.addDirtyRect( this.AABB ); +1250 } +1251 } +1252 this.dirty= false; +1253 this.invalid= false; 1254 }, 1255 /** 1256 * Calculates the 2D bounding box in canvas coordinates of the Actor. @@ -1875,7 +1875,7 @@ 1868 for( i=0, l=markDelete.length; i<l; i++ ) { 1869 var md= markDelete[i]; 1870 md.destroy(time); -1871 if ( !director.dirtyRectsEnabled ) { +1871 if ( director.dirtyRectsEnabled ) { 1872 director.addDirtyRect( md.AABB ); 1873 } 1874 } diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html index ab021380..12b52488 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html @@ -596,1001 +596,1001 @@ 589 if ( this.dirtyRectsEnabled ) { 590 591 ctx.beginPath(); -592 var dr= this.cDirtyRects; -593 for( i=0; i<dr.length; i++ ) { -594 var drr= dr[i]; -595 if ( !drr.isEmpty() ) { -596 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); -597 } -598 } -599 ctx.clip(); -600 } else if (this.clear===true ) { -601 ctx.clearRect(0, 0, this.width, this.height); -602 } -603 -604 for (i = 0; i < ne; i++) { -605 c= this.childrenList[i]; -606 -607 if (c.isInAnimationFrame(this.time)) { -608 tt = c.time - c.start_time; -609 ctx.save(); -610 -611 if ( c.onRenderStart ) { -612 c.onRenderStart(tt); -613 } -614 c.paintActor(this, tt); -615 if ( c.onRenderEnd ) { -616 c.onRenderEnd(tt); -617 } -618 ctx.restore(); -619 -620 if (CAAT.DEBUGAABB) { -621 ctx.globalAlpha= 1; -622 ctx.globalCompositeOperation= 'source-over'; -623 this.modelViewMatrix.transformRenderingContextSet( ctx ); -624 c.drawScreenBoundingBox(this, tt); -625 } -626 -627 if ( !c.isPaused() ) { -628 c.time += time; -629 } -630 -631 if ( CAAT.DEBUG ) { -632 this.statistics.size_total+= c.size_total; -633 this.statistics.size_active+= c.size_active; -634 } -635 -636 } -637 } -638 -639 ctx.restore(); -640 } -641 -642 this.frameCounter++; -643 }, -644 /** -645 * A director is a very special kind of actor. -646 * Its animation routine simple sets its modelViewMatrix in case some transformation's been -647 * applied. -648 * No behaviors are allowed for Director instances. -649 * @param director {CAAT.Director} redundant reference to CAAT.Director itself -650 * @param time {number} director time. -651 */ -652 animate : function(director, time) { -653 this.setModelViewMatrix(this); -654 -655 this.dirtyRectsIndex= -1; -656 this.cDirtyRects= []; -657 -658 var cl= this.childrenList; -659 var cli; -660 for (var i = 0; i < cl.length; i++) { -661 cli= cl[i]; -662 var tt = cli.time - cli.start_time; -663 cli.animate(this, tt); -664 } -665 -666 return this; -667 }, -668 /** -669 * Add a rectangle to the list of dirty screen areas which should be redrawn. -670 * This is the opposite method to clear the whole screen and repaint everything again. -671 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this -672 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or -673 * even lowers performance under others, so it is a developer choice to activate them via a call to -674 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). -675 * -676 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping -677 * rectangles will be removed and intersecting ones will be unioned. +592 ctx.rect(0,0,120,40); +593 var dr= this.cDirtyRects; +594 for( i=0; i<dr.length; i++ ) { +595 var drr= dr[i]; +596 if ( !drr.isEmpty() ) { +597 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); +598 } +599 } +600 ctx.clip(); +601 } else if (this.clear===true ) { +602 ctx.clearRect(0, 0, this.width, this.height); +603 } +604 +605 for (i = 0; i < ne; i++) { +606 c= this.childrenList[i]; +607 +608 if (c.isInAnimationFrame(this.time)) { +609 tt = c.time - c.start_time; +610 ctx.save(); +611 +612 if ( c.onRenderStart ) { +613 c.onRenderStart(tt); +614 } +615 c.paintActor(this, tt); +616 if ( c.onRenderEnd ) { +617 c.onRenderEnd(tt); +618 } +619 ctx.restore(); +620 +621 if (CAAT.DEBUGAABB) { +622 ctx.globalAlpha= 1; +623 ctx.globalCompositeOperation= 'source-over'; +624 this.modelViewMatrix.transformRenderingContextSet( ctx ); +625 c.drawScreenBoundingBox(this, tt); +626 } +627 +628 if ( !c.isPaused() ) { +629 c.time += time; +630 } +631 +632 if ( CAAT.DEBUG ) { +633 this.statistics.size_total+= c.size_total; +634 this.statistics.size_active+= c.size_active; +635 } +636 +637 } +638 } +639 +640 ctx.restore(); +641 } +642 +643 this.frameCounter++; +644 }, +645 /** +646 * A director is a very special kind of actor. +647 * Its animation routine simple sets its modelViewMatrix in case some transformation's been +648 * applied. +649 * No behaviors are allowed for Director instances. +650 * @param director {CAAT.Director} redundant reference to CAAT.Director itself +651 * @param time {number} director time. +652 */ +653 animate : function(director, time) { +654 this.setModelViewMatrix(this); +655 +656 this.dirty= false; +657 this.invalid= false; +658 this.dirtyRectsIndex= -1; +659 this.cDirtyRects= []; +660 +661 var cl= this.childrenList; +662 var cli; +663 for (var i = 0; i < cl.length; i++) { +664 cli= cl[i]; +665 var tt = cli.time - cli.start_time; +666 cli.animate(this, tt); +667 } +668 +669 return this; +670 }, +671 /** +672 * Add a rectangle to the list of dirty screen areas which should be redrawn. +673 * This is the opposite method to clear the whole screen and repaint everything again. +674 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this +675 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or +676 * even lowers performance under others, so it is a developer choice to activate them via a call to +677 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). 678 * -679 * Before calling this method, check if this.dirtyRectsEnabled is true. -680 * -681 * @param rectangle {CAAT.Rectangle} -682 */ -683 addDirtyRect : function( rectangle ) { -684 -685 if ( rectangle.isEmpty() ) { -686 return; -687 } -688 -689 var i, dr, j, drj; -690 var cdr= this.cDirtyRects; -691 for( i=0; i<cdr.length; i++ ) { -692 dr= cdr[i]; -693 if ( dr.intersects( rectangle ) ) { -694 dr.unionRectangle( rectangle ); -695 -696 for( j=0; j<cdr.length; j++ ) { -697 if ( j!==i ) { -698 drj= cdr[j]; -699 if ( drj.intersects( dr ) ) { -700 dr.unionRectangle( drj ); -701 drj.setEmpty(); -702 } -703 } -704 } -705 -706 for( j=0; j<cdr.length; j++ ) { -707 if ( cdr[j].isEmpty() ) { -708 cdr.splice( j, 1 ); -709 } -710 } -711 -712 return; -713 } -714 } -715 -716 this.dirtyRectsIndex++; +679 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping +680 * rectangles will be removed and intersecting ones will be unioned. +681 * +682 * Before calling this method, check if this.dirtyRectsEnabled is true. +683 * +684 * @param rectangle {CAAT.Rectangle} +685 */ +686 addDirtyRect : function( rectangle ) { +687 +688 if ( rectangle.isEmpty() ) { +689 return; +690 } +691 +692 var i, dr, j, drj; +693 var cdr= this.cDirtyRects; +694 +695 for( i=0; i<cdr.length; i++ ) { +696 dr= cdr[i]; +697 if ( !dr.isEmpty() && dr.intersects( rectangle ) ) { +698 var intersected= true; +699 while( intersected ) { +700 dr.unionRectangle( rectangle ); +701 +702 for( j=0; j<cdr.length; j++ ) { +703 if ( j!==i ) { +704 drj= cdr[j]; +705 if ( !drj.isEmpty() && drj.intersects( dr ) ) { +706 dr.unionRectangle( drj ); +707 drj.setEmpty(); +708 break; +709 } +710 } +711 } +712 +713 if ( j==cdr.length ) { +714 intersected= false; +715 } +716 } 717 -718 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { -719 for( i=0; i<32; i++ ) { -720 this.dirtyRects.push( new CAAT.Rectangle() ); -721 } -722 } +718 for( j=0; j<cdr.length; j++ ) { +719 if ( cdr[j].isEmpty() ) { +720 cdr.splice( j, 1 ); +721 } +722 } 723 -724 var r= this.dirtyRects[ this.dirtyRectsIndex ]; -725 -726 r.x= rectangle.x; -727 r.y= rectangle.y; -728 r.x1= rectangle.x1; -729 r.y1= rectangle.y1; -730 r.width= rectangle.width; -731 r.height= rectangle.height; -732 -733 this.cDirtyRects.push( r ); -734 -735 }, -736 /** -737 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of -738 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from -739 * one to another, first of all an scene is drawn to offscreen, and that image is translated. -740 * <p> -741 * Until the creation of this method, both scenes where drawn while transitioning with -742 * its performance penalty since drawing two scenes could be twice as expensive than drawing -743 * only one. -744 * <p> -745 * Though a high performance increase, we should keep an eye on memory consumption. -746 * -747 * @param ctx a <code>canvas.getContext('2d')</code> instnce. -748 * @param scene {CAAT.Scene} the scene to draw offscreen. -749 */ -750 renderToContext : function(ctx, scene) { -751 /** -752 * draw actors on scene. -753 */ -754 if (scene.isInAnimationFrame(this.time)) { -755 ctx.globalAlpha = 1; -756 ctx.globalCompositeOperation = 'source-over'; -757 ctx.clearRect(0, 0, this.width, this.height); -758 ctx.setTransform(1,0,0, 0,1,0); -759 -760 var octx = this.ctx; -761 var ocrc = this.crc; -762 -763 this.ctx = this.crc = ctx; -764 ctx.save(); -765 -766 /** -767 * to draw an scene to an offscreen canvas, we have to: -768 * 1.- save diector's world model view matrix -769 * 2.- set no transformation on director since we want the offscreen to -770 * be drawn 1:1. -771 * 3.- set world dirty flag, so that the scene will recalculate its matrices -772 * 4.- animate the scene -773 * 5.- paint the scene -774 * 6.- restore world model view matrix. -775 */ -776 var matwmv= this.worldModelViewMatrix; -777 this.worldModelViewMatrix= new CAAT.Matrix(); -778 this.wdirty= true; -779 scene.animate(this, scene.time); -780 if ( scene.onRenderStart ) { -781 scene.onRenderStart(scene.time); -782 } -783 scene.paintActor(this, scene.time); -784 if ( scene.onRenderEnd ) { -785 scene.onRenderEnd(scene.time); -786 } -787 this.worldModelViewMatrix = matwmv; -788 -789 ctx.restore(); -790 -791 this.ctx = octx; -792 this.crc = ocrc; -793 } -794 }, -795 /** -796 * Add a new Scene to Director's Scene list. By adding a Scene to the Director -797 * does not mean it will be immediately visible, you should explicitly call either -798 * <ul> -799 * <li>easeIn -800 * <li>easeInOut -801 * <li>easeInOutRandom -802 * <li>setScene -803 * <li>or any of the scene switching methods -804 * </ul> -805 * -806 * @param scene {CAAT.Scene} an CAAT.Scene object. -807 */ -808 addScene : function(scene) { -809 scene.setBounds(0, 0, this.width, this.height); -810 this.scenes.push(scene); -811 scene.setEaseListener(this); -812 if (null === this.currentScene) { -813 this.setScene(0); -814 } -815 }, -816 /** -817 * Get the number of scenes contained in the Director. -818 * @return {number} the number of scenes contained in the Director. +724 return; +725 } +726 } +727 +728 this.dirtyRectsIndex++; +729 +730 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { +731 for( i=0; i<32; i++ ) { +732 this.dirtyRects.push( new CAAT.Rectangle() ); +733 } +734 } +735 +736 var r= this.dirtyRects[ this.dirtyRectsIndex ]; +737 +738 r.x= rectangle.x; +739 r.y= rectangle.y; +740 r.x1= rectangle.x1; +741 r.y1= rectangle.y1; +742 r.width= rectangle.width; +743 r.height= rectangle.height; +744 +745 this.cDirtyRects.push( r ); +746 +747 }, +748 /** +749 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of +750 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from +751 * one to another, first of all an scene is drawn to offscreen, and that image is translated. +752 * <p> +753 * Until the creation of this method, both scenes where drawn while transitioning with +754 * its performance penalty since drawing two scenes could be twice as expensive than drawing +755 * only one. +756 * <p> +757 * Though a high performance increase, we should keep an eye on memory consumption. +758 * +759 * @param ctx a <code>canvas.getContext('2d')</code> instnce. +760 * @param scene {CAAT.Scene} the scene to draw offscreen. +761 */ +762 renderToContext : function(ctx, scene) { +763 /** +764 * draw actors on scene. +765 */ +766 if (scene.isInAnimationFrame(this.time)) { +767 ctx.globalAlpha = 1; +768 ctx.globalCompositeOperation = 'source-over'; +769 ctx.clearRect(0, 0, this.width, this.height); +770 ctx.setTransform(1,0,0, 0,1,0); +771 +772 var octx = this.ctx; +773 var ocrc = this.crc; +774 +775 this.ctx = this.crc = ctx; +776 ctx.save(); +777 +778 /** +779 * to draw an scene to an offscreen canvas, we have to: +780 * 1.- save diector's world model view matrix +781 * 2.- set no transformation on director since we want the offscreen to +782 * be drawn 1:1. +783 * 3.- set world dirty flag, so that the scene will recalculate its matrices +784 * 4.- animate the scene +785 * 5.- paint the scene +786 * 6.- restore world model view matrix. +787 */ +788 var matwmv= this.worldModelViewMatrix; +789 this.worldModelViewMatrix= new CAAT.Matrix(); +790 this.wdirty= true; +791 scene.animate(this, scene.time); +792 if ( scene.onRenderStart ) { +793 scene.onRenderStart(scene.time); +794 } +795 scene.paintActor(this, scene.time); +796 if ( scene.onRenderEnd ) { +797 scene.onRenderEnd(scene.time); +798 } +799 this.worldModelViewMatrix = matwmv; +800 +801 ctx.restore(); +802 +803 this.ctx = octx; +804 this.crc = ocrc; +805 } +806 }, +807 /** +808 * Add a new Scene to Director's Scene list. By adding a Scene to the Director +809 * does not mean it will be immediately visible, you should explicitly call either +810 * <ul> +811 * <li>easeIn +812 * <li>easeInOut +813 * <li>easeInOutRandom +814 * <li>setScene +815 * <li>or any of the scene switching methods +816 * </ul> +817 * +818 * @param scene {CAAT.Scene} an CAAT.Scene object. 819 */ -820 getNumScenes : function() { -821 return this.scenes.length; -822 }, -823 /** -824 * This method offers full control over the process of switching between any given two Scenes. -825 * To apply this method, you must specify the type of transition to apply for each Scene and -826 * the anchor to keep the Scene pinned at. -827 * <p> -828 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: -829 * <ul> -830 * <li>EASE_ROTATION -831 * <li>EASE_SCALE -832 * <li>EASE_TRANSLATION -833 * </ul> -834 * -835 * <p> -836 * The anchor will be any of these values defined in CAAT.Actor.prototype: -837 * <ul> -838 * <li>ANCHOR_CENTER -839 * <li>ANCHOR_TOP -840 * <li>ANCHOR_BOTTOM -841 * <li>ANCHOR_LEFT -842 * <li>ANCHOR_RIGHT -843 * <li>ANCHOR_TOP_LEFT -844 * <li>ANCHOR_TOP_RIGHT -845 * <li>ANCHOR_BOTTOM_LEFT -846 * <li>ANCHOR_BOTTOM_RIGHT -847 * </ul> -848 * -849 * <p> -850 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the -851 * point by which the scene will scaled. -852 * -853 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. -854 * @param typein integer indicating the type of transition to apply to the bringing in Scene. -855 * @param anchorin integer indicating the anchor of the bringing in Scene. -856 * @param outSceneIndex integer indicating the Scene index to take away from the Director. -857 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. -858 * @param anchorout integer indicating the anchor of the taking away Scene. -859 * @param time inteter indicating the time to perform the process of switchihg between Scene object -860 * in milliseconds. -861 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to -862 * the scenes. -863 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. -864 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. -865 */ -866 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { -867 -868 if (inSceneIndex === this.getCurrentSceneIndex()) { -869 return; -870 } -871 -872 var ssin = this.scenes[ inSceneIndex ]; -873 var sout = this.scenes[ outSceneIndex ]; -874 -875 if (!this.glEnabled && !navigator.browser==='iOS') { -876 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); -877 this.renderToContext(this.transitionScene.ctx, sout); -878 sout = this.transitionScene; -879 } -880 -881 ssin.setExpired(false); -882 sout.setExpired(false); +820 addScene : function(scene) { +821 scene.setBounds(0, 0, this.width, this.height); +822 this.scenes.push(scene); +823 scene.setEaseListener(this); +824 if (null === this.currentScene) { +825 this.setScene(0); +826 } +827 }, +828 /** +829 * Get the number of scenes contained in the Director. +830 * @return {number} the number of scenes contained in the Director. +831 */ +832 getNumScenes : function() { +833 return this.scenes.length; +834 }, +835 /** +836 * This method offers full control over the process of switching between any given two Scenes. +837 * To apply this method, you must specify the type of transition to apply for each Scene and +838 * the anchor to keep the Scene pinned at. +839 * <p> +840 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: +841 * <ul> +842 * <li>EASE_ROTATION +843 * <li>EASE_SCALE +844 * <li>EASE_TRANSLATION +845 * </ul> +846 * +847 * <p> +848 * The anchor will be any of these values defined in CAAT.Actor.prototype: +849 * <ul> +850 * <li>ANCHOR_CENTER +851 * <li>ANCHOR_TOP +852 * <li>ANCHOR_BOTTOM +853 * <li>ANCHOR_LEFT +854 * <li>ANCHOR_RIGHT +855 * <li>ANCHOR_TOP_LEFT +856 * <li>ANCHOR_TOP_RIGHT +857 * <li>ANCHOR_BOTTOM_LEFT +858 * <li>ANCHOR_BOTTOM_RIGHT +859 * </ul> +860 * +861 * <p> +862 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the +863 * point by which the scene will scaled. +864 * +865 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. +866 * @param typein integer indicating the type of transition to apply to the bringing in Scene. +867 * @param anchorin integer indicating the anchor of the bringing in Scene. +868 * @param outSceneIndex integer indicating the Scene index to take away from the Director. +869 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. +870 * @param anchorout integer indicating the anchor of the taking away Scene. +871 * @param time inteter indicating the time to perform the process of switchihg between Scene object +872 * in milliseconds. +873 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to +874 * the scenes. +875 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. +876 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. +877 */ +878 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { +879 +880 if (inSceneIndex === this.getCurrentSceneIndex()) { +881 return; +882 } 883 -884 ssin.mouseEnabled = false; -885 sout.mouseEnabled = false; +884 var ssin = this.scenes[ inSceneIndex ]; +885 var sout = this.scenes[ outSceneIndex ]; 886 -887 ssin.resetTransform(); -888 sout.resetTransform(); -889 -890 ssin.setLocation(0, 0); -891 sout.setLocation(0, 0); +887 if (!this.glEnabled && !navigator.browser==='iOS') { +888 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); +889 this.renderToContext(this.transitionScene.ctx, sout); +890 sout = this.transitionScene; +891 } 892 -893 ssin.alpha = 1; -894 sout.alpha = 1; +893 ssin.setExpired(false); +894 sout.setExpired(false); 895 -896 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { -897 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); -898 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { -899 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); -900 } else { -901 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); -902 } -903 -904 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { -905 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); -906 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { -907 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); -908 } else { -909 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); -910 } -911 -912 this.childrenList = []; -913 -914 this.addChild(sout); -915 this.addChild(ssin); -916 }, -917 /** -918 * This method will switch between two given Scene indexes (ie, take away scene number 2, -919 * and bring in scene number 5). -920 * <p> -921 * It will randomly choose for each Scene the type of transition to apply and the anchor -922 * point of each transition type. -923 * <p> -924 * It will also set for different kind of transitions the following interpolators: -925 * <ul> -926 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. -927 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 -928 * <li>EASE_TRANSLATION -> BounceOutInterpolator -929 * </ul> -930 * -931 * <p> -932 * These are the default values, and could not be changed by now. -933 * This method in final instance delegates the process to easeInOutMethod. -934 * -935 * @see easeInOutMethod. -936 * -937 * @param inIndex integer indicating the entering scene index. -938 * @param outIndex integer indicating the exiting scene index. -939 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. -940 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. -941 */ -942 easeInOutRandom : function(inIndex, outIndex, time, alpha) { -943 -944 var pin = Math.random(); -945 var pout = Math.random(); -946 -947 var typeIn; -948 var interpolatorIn; -949 -950 if (pin < 0.33) { -951 typeIn = CAAT.Scene.prototype.EASE_ROTATION; -952 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -953 } else if (pin < 0.66) { -954 typeIn = CAAT.Scene.prototype.EASE_SCALE; -955 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); -956 } else { -957 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; -958 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); -959 } -960 -961 var typeOut; -962 var interpolatorOut; -963 -964 if (pout < 0.33) { -965 typeOut = CAAT.Scene.prototype.EASE_ROTATION; -966 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -967 } else if (pout < 0.66) { -968 typeOut = CAAT.Scene.prototype.EASE_SCALE; -969 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); -970 } else { -971 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; -972 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); -973 } -974 -975 this.easeInOut( -976 inIndex, -977 typeIn, -978 (Math.random() * 8.99) >> 0, -979 -980 outIndex, -981 typeOut, -982 (Math.random() * 8.99) >> 0, -983 -984 time, -985 alpha, +896 ssin.mouseEnabled = false; +897 sout.mouseEnabled = false; +898 +899 ssin.resetTransform(); +900 sout.resetTransform(); +901 +902 ssin.setLocation(0, 0); +903 sout.setLocation(0, 0); +904 +905 ssin.alpha = 1; +906 sout.alpha = 1; +907 +908 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { +909 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); +910 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { +911 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); +912 } else { +913 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); +914 } +915 +916 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { +917 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); +918 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { +919 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); +920 } else { +921 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); +922 } +923 +924 this.childrenList = []; +925 +926 this.addChild(sout); +927 this.addChild(ssin); +928 }, +929 /** +930 * This method will switch between two given Scene indexes (ie, take away scene number 2, +931 * and bring in scene number 5). +932 * <p> +933 * It will randomly choose for each Scene the type of transition to apply and the anchor +934 * point of each transition type. +935 * <p> +936 * It will also set for different kind of transitions the following interpolators: +937 * <ul> +938 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +939 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +940 * <li>EASE_TRANSLATION -> BounceOutInterpolator +941 * </ul> +942 * +943 * <p> +944 * These are the default values, and could not be changed by now. +945 * This method in final instance delegates the process to easeInOutMethod. +946 * +947 * @see easeInOutMethod. +948 * +949 * @param inIndex integer indicating the entering scene index. +950 * @param outIndex integer indicating the exiting scene index. +951 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. +952 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. +953 */ +954 easeInOutRandom : function(inIndex, outIndex, time, alpha) { +955 +956 var pin = Math.random(); +957 var pout = Math.random(); +958 +959 var typeIn; +960 var interpolatorIn; +961 +962 if (pin < 0.33) { +963 typeIn = CAAT.Scene.prototype.EASE_ROTATION; +964 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +965 } else if (pin < 0.66) { +966 typeIn = CAAT.Scene.prototype.EASE_SCALE; +967 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); +968 } else { +969 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; +970 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); +971 } +972 +973 var typeOut; +974 var interpolatorOut; +975 +976 if (pout < 0.33) { +977 typeOut = CAAT.Scene.prototype.EASE_ROTATION; +978 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +979 } else if (pout < 0.66) { +980 typeOut = CAAT.Scene.prototype.EASE_SCALE; +981 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); +982 } else { +983 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; +984 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); +985 } 986 -987 interpolatorIn, -988 interpolatorOut); -989 -990 }, -991 /** -992 * This method changes Director's current Scene to the scene index indicated by -993 * inSceneIndex parameter. The Scene running in the director won't be eased out. -994 * -995 * @see {CAAT.Interpolator} -996 * @see {CAAT.Actor} -997 * @see {CAAT.Scene} -998 * -999 * @param inSceneIndex integer indicating the new Scene to set as current. -1000 * @param type integer indicating the type of transition to apply to bring the new current -1001 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, -1002 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. -1003 * @param time integer indicating how much time in milliseconds the Scene entrance will take. -1004 * @param alpha boolean indicating whether alpha transparency fading will be applied to the -1005 * entereing Scene. -1006 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of -1007 * CAAT.Actor.prototype.ANCHOR_* values. -1008 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to -1009 * apply. -1010 */ -1011 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { -1012 var sin = this.scenes[ inSceneIndex ]; -1013 if (type === CAAT.Scene.prototype.EASE_ROTATION) { -1014 sin.easeRotationIn(time, alpha, anchor, interpolator); -1015 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { -1016 sin.easeScaleIn(0, time, alpha, anchor, interpolator); -1017 } else { -1018 sin.easeTranslationIn(time, alpha, anchor, interpolator); -1019 } -1020 this.childrenList = []; -1021 this.addChild(sin); -1022 -1023 sin.resetTransform(); -1024 sin.setLocation(0, 0); -1025 sin.alpha = 1; -1026 sin.mouseEnabled = false; -1027 sin.setExpired(false); -1028 }, -1029 /** -1030 * Changes (or sets) the current Director scene to the index -1031 * parameter. There will be no transition on scene change. -1032 * @param sceneIndex {number} an integer indicating the index of the target Scene -1033 * to be shown. -1034 */ -1035 setScene : function(sceneIndex) { -1036 var sin = this.scenes[ sceneIndex ]; -1037 this.childrenList = []; -1038 this.addChild(sin); -1039 this.currentScene = sin; -1040 -1041 sin.setExpired(false); -1042 sin.mouseEnabled = true; -1043 sin.resetTransform(); -1044 sin.setLocation(0, 0); -1045 sin.alpha = 1; -1046 -1047 sin.activated(); -1048 }, -1049 /** -1050 * This method will change the current Scene by the Scene indicated as parameter. -1051 * It will apply random values for anchor and transition type. -1052 * @see easeInOutRandom -1053 * -1054 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. -1055 * @param time {number} an integer indicating the time the Scene transition will take. -1056 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1057 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1058 */ -1059 switchToScene : function(iNewSceneIndex, time, alpha, transition) { -1060 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1061 -1062 if (!transition) { -1063 this.setScene(iNewSceneIndex); -1064 } -1065 else { -1066 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); -1067 } -1068 }, -1069 /** -1070 * Sets the previous Scene in sequence as the current Scene. -1071 * @see switchToScene. -1072 * -1073 * @param time {number} integer indicating the time the Scene transition will take. -1074 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1075 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1076 */ -1077 switchToPrevScene : function(time, alpha, transition) { -1078 -1079 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1080 -1081 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { -1082 return; -1083 } -1084 -1085 if (!transition) { -1086 this.setScene(currentSceneIndex - 1); -1087 } -1088 else { -1089 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); -1090 } -1091 }, -1092 /** -1093 * Sets the previous Scene in sequence as the current Scene. -1094 * @see switchToScene. -1095 * -1096 * @param time {number} integer indicating the time the Scene transition will take. -1097 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1098 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1099 */ -1100 switchToNextScene: function(time, alpha, transition) { -1101 -1102 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1103 -1104 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { -1105 return; -1106 } -1107 -1108 if (!transition) { -1109 this.setScene(currentSceneIndex + 1); -1110 } -1111 else { -1112 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); -1113 } -1114 }, -1115 mouseEnter : function(mouseEvent) { -1116 }, -1117 mouseExit : function(mouseEvent) { -1118 }, -1119 mouseMove : function(mouseEvent) { -1120 }, -1121 mouseDown : function(mouseEvent) { -1122 }, -1123 mouseUp : function(mouseEvent) { -1124 }, -1125 mouseDrag : function(mouseEvent) { +987 this.easeInOut( +988 inIndex, +989 typeIn, +990 (Math.random() * 8.99) >> 0, +991 +992 outIndex, +993 typeOut, +994 (Math.random() * 8.99) >> 0, +995 +996 time, +997 alpha, +998 +999 interpolatorIn, +1000 interpolatorOut); +1001 +1002 }, +1003 /** +1004 * This method changes Director's current Scene to the scene index indicated by +1005 * inSceneIndex parameter. The Scene running in the director won't be eased out. +1006 * +1007 * @see {CAAT.Interpolator} +1008 * @see {CAAT.Actor} +1009 * @see {CAAT.Scene} +1010 * +1011 * @param inSceneIndex integer indicating the new Scene to set as current. +1012 * @param type integer indicating the type of transition to apply to bring the new current +1013 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, +1014 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. +1015 * @param time integer indicating how much time in milliseconds the Scene entrance will take. +1016 * @param alpha boolean indicating whether alpha transparency fading will be applied to the +1017 * entereing Scene. +1018 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of +1019 * CAAT.Actor.prototype.ANCHOR_* values. +1020 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to +1021 * apply. +1022 */ +1023 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { +1024 var sin = this.scenes[ inSceneIndex ]; +1025 if (type === CAAT.Scene.prototype.EASE_ROTATION) { +1026 sin.easeRotationIn(time, alpha, anchor, interpolator); +1027 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { +1028 sin.easeScaleIn(0, time, alpha, anchor, interpolator); +1029 } else { +1030 sin.easeTranslationIn(time, alpha, anchor, interpolator); +1031 } +1032 this.childrenList = []; +1033 this.addChild(sin); +1034 +1035 sin.resetTransform(); +1036 sin.setLocation(0, 0); +1037 sin.alpha = 1; +1038 sin.mouseEnabled = false; +1039 sin.setExpired(false); +1040 }, +1041 /** +1042 * Changes (or sets) the current Director scene to the index +1043 * parameter. There will be no transition on scene change. +1044 * @param sceneIndex {number} an integer indicating the index of the target Scene +1045 * to be shown. +1046 */ +1047 setScene : function(sceneIndex) { +1048 var sin = this.scenes[ sceneIndex ]; +1049 this.childrenList = []; +1050 this.addChild(sin); +1051 this.currentScene = sin; +1052 +1053 sin.setExpired(false); +1054 sin.mouseEnabled = true; +1055 sin.resetTransform(); +1056 sin.setLocation(0, 0); +1057 sin.alpha = 1; +1058 +1059 sin.activated(); +1060 }, +1061 /** +1062 * This method will change the current Scene by the Scene indicated as parameter. +1063 * It will apply random values for anchor and transition type. +1064 * @see easeInOutRandom +1065 * +1066 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. +1067 * @param time {number} an integer indicating the time the Scene transition will take. +1068 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1069 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1070 */ +1071 switchToScene : function(iNewSceneIndex, time, alpha, transition) { +1072 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1073 +1074 if (!transition) { +1075 this.setScene(iNewSceneIndex); +1076 } +1077 else { +1078 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); +1079 } +1080 }, +1081 /** +1082 * Sets the previous Scene in sequence as the current Scene. +1083 * @see switchToScene. +1084 * +1085 * @param time {number} integer indicating the time the Scene transition will take. +1086 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1087 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1088 */ +1089 switchToPrevScene : function(time, alpha, transition) { +1090 +1091 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1092 +1093 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { +1094 return; +1095 } +1096 +1097 if (!transition) { +1098 this.setScene(currentSceneIndex - 1); +1099 } +1100 else { +1101 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); +1102 } +1103 }, +1104 /** +1105 * Sets the previous Scene in sequence as the current Scene. +1106 * @see switchToScene. +1107 * +1108 * @param time {number} integer indicating the time the Scene transition will take. +1109 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1110 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1111 */ +1112 switchToNextScene: function(time, alpha, transition) { +1113 +1114 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1115 +1116 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { +1117 return; +1118 } +1119 +1120 if (!transition) { +1121 this.setScene(currentSceneIndex + 1); +1122 } +1123 else { +1124 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); +1125 } 1126 }, -1127 /** -1128 * Scene easing listener. Notifies scenes when they're about to be activated (set as current -1129 * director's scene). -1130 * -1131 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. -1132 * @param b_easeIn {boolean} scene enters or exits ? -1133 */ -1134 easeEnd : function(scene, b_easeIn) { -1135 // scene is going out -1136 if (!b_easeIn) { -1137 -1138 scene.setExpired(true); -1139 } else { -1140 this.currentScene = scene; -1141 this.currentScene.activated(); -1142 } -1143 -1144 scene.mouseEnabled = true; -1145 scene.emptyBehaviorList(); -1146 }, -1147 /** -1148 * Return the index for a given Scene object contained in the Director. -1149 * @param scene {CAAT.Scene} -1150 */ -1151 getSceneIndex : function(scene) { -1152 for (var i = 0; i < this.scenes.length; i++) { -1153 if (this.scenes[i] === scene) { -1154 return i; -1155 } -1156 } -1157 return -1; +1127 mouseEnter : function(mouseEvent) { +1128 }, +1129 mouseExit : function(mouseEvent) { +1130 }, +1131 mouseMove : function(mouseEvent) { +1132 }, +1133 mouseDown : function(mouseEvent) { +1134 }, +1135 mouseUp : function(mouseEvent) { +1136 }, +1137 mouseDrag : function(mouseEvent) { +1138 }, +1139 /** +1140 * Scene easing listener. Notifies scenes when they're about to be activated (set as current +1141 * director's scene). +1142 * +1143 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. +1144 * @param b_easeIn {boolean} scene enters or exits ? +1145 */ +1146 easeEnd : function(scene, b_easeIn) { +1147 // scene is going out +1148 if (!b_easeIn) { +1149 +1150 scene.setExpired(true); +1151 } else { +1152 this.currentScene = scene; +1153 this.currentScene.activated(); +1154 } +1155 +1156 scene.mouseEnabled = true; +1157 scene.emptyBehaviorList(); 1158 }, 1159 /** -1160 * Get a concrete director's scene. -1161 * @param index {number} an integer indicating the scene index. -1162 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. -1163 */ -1164 getScene : function(index) { -1165 return this.scenes[index]; -1166 }, -1167 /** -1168 * Return the index of the current scene in the Director's scene list. -1169 * @return {number} the current scene's index. -1170 */ -1171 getCurrentSceneIndex : function() { -1172 return this.getSceneIndex(this.currentScene); -1173 }, -1174 /** -1175 * Return the running browser name. -1176 * @return {string} the browser name. -1177 */ -1178 getBrowserName : function() { -1179 return this.browserInfo.browser; -1180 }, -1181 /** -1182 * Return the running browser version. -1183 * @return {string} the browser version. -1184 */ -1185 getBrowserVersion : function() { -1186 return this.browserInfo.version; -1187 }, -1188 /** -1189 * Return the operating system name. -1190 * @return {string} the os name. -1191 */ -1192 getOSName : function() { -1193 return this.browserInfo.OS; -1194 }, -1195 /** -1196 * Gets the resource with the specified resource name. -1197 * The Director holds a collection called <code>imagesCache</code> -1198 * where you can store a JSON of the form -1199 * <code>[ { id: imageId, image: imageObject } ]</code>. -1200 * This structure will be used as a resources cache. -1201 * There's a CAAT.ImagePreloader class to preload resources and -1202 * generate this structure on loading finalization. -1203 * -1204 * @param sId {object} an String identifying a resource. -1205 */ -1206 getImage : function(sId) { -1207 var ret = this.imagesCache[sId]; -1208 if (ret) { -1209 return ret; -1210 } -1211 -1212 for (var i = 0; i < this.imagesCache.length; i++) { -1213 if (this.imagesCache[i].id === sId) { -1214 return this.imagesCache[i].image; -1215 } -1216 } -1217 -1218 return null; -1219 }, -1220 /** -1221 * Adds an audio to the cache. -1222 * -1223 * @see CAAT.AudioManager.addAudio -1224 * @return this -1225 */ -1226 addAudio : function(id, url) { -1227 this.audioManager.addAudio(id, url); -1228 return this; -1229 }, -1230 /** -1231 * Plays the audio instance identified by the id. -1232 * @param id {object} the object used to store a sound in the audioCache. -1233 */ -1234 audioPlay : function(id) { -1235 this.audioManager.play(id); -1236 }, -1237 /** -1238 * Loops an audio instance identified by the id. -1239 * @param id {object} the object used to store a sound in the audioCache. -1240 * -1241 * @return {HTMLElement|null} the value from audioManager.loop -1242 */ -1243 audioLoop : function(id) { -1244 return this.audioManager.loop(id); -1245 }, -1246 endSound : function() { -1247 return this.audioManager.endSound(); +1160 * Return the index for a given Scene object contained in the Director. +1161 * @param scene {CAAT.Scene} +1162 */ +1163 getSceneIndex : function(scene) { +1164 for (var i = 0; i < this.scenes.length; i++) { +1165 if (this.scenes[i] === scene) { +1166 return i; +1167 } +1168 } +1169 return -1; +1170 }, +1171 /** +1172 * Get a concrete director's scene. +1173 * @param index {number} an integer indicating the scene index. +1174 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. +1175 */ +1176 getScene : function(index) { +1177 return this.scenes[index]; +1178 }, +1179 /** +1180 * Return the index of the current scene in the Director's scene list. +1181 * @return {number} the current scene's index. +1182 */ +1183 getCurrentSceneIndex : function() { +1184 return this.getSceneIndex(this.currentScene); +1185 }, +1186 /** +1187 * Return the running browser name. +1188 * @return {string} the browser name. +1189 */ +1190 getBrowserName : function() { +1191 return this.browserInfo.browser; +1192 }, +1193 /** +1194 * Return the running browser version. +1195 * @return {string} the browser version. +1196 */ +1197 getBrowserVersion : function() { +1198 return this.browserInfo.version; +1199 }, +1200 /** +1201 * Return the operating system name. +1202 * @return {string} the os name. +1203 */ +1204 getOSName : function() { +1205 return this.browserInfo.OS; +1206 }, +1207 /** +1208 * Gets the resource with the specified resource name. +1209 * The Director holds a collection called <code>imagesCache</code> +1210 * where you can store a JSON of the form +1211 * <code>[ { id: imageId, image: imageObject } ]</code>. +1212 * This structure will be used as a resources cache. +1213 * There's a CAAT.ImagePreloader class to preload resources and +1214 * generate this structure on loading finalization. +1215 * +1216 * @param sId {object} an String identifying a resource. +1217 */ +1218 getImage : function(sId) { +1219 var ret = this.imagesCache[sId]; +1220 if (ret) { +1221 return ret; +1222 } +1223 +1224 for (var i = 0; i < this.imagesCache.length; i++) { +1225 if (this.imagesCache[i].id === sId) { +1226 return this.imagesCache[i].image; +1227 } +1228 } +1229 +1230 return null; +1231 }, +1232 /** +1233 * Adds an audio to the cache. +1234 * +1235 * @see CAAT.AudioManager.addAudio +1236 * @return this +1237 */ +1238 addAudio : function(id, url) { +1239 this.audioManager.addAudio(id, url); +1240 return this; +1241 }, +1242 /** +1243 * Plays the audio instance identified by the id. +1244 * @param id {object} the object used to store a sound in the audioCache. +1245 */ +1246 audioPlay : function(id) { +1247 this.audioManager.play(id); 1248 }, -1249 setSoundEffectsEnabled : function(enabled) { -1250 return this.audioManager.setSoundEffectsEnabled(enabled); -1251 }, -1252 setMusicEnabled : function(enabled) { -1253 return this.audioManager.setMusicEnabled(enabled); -1254 }, -1255 isMusicEnabled : function() { -1256 return this.audioManager.isMusicEnabled(); +1249 /** +1250 * Loops an audio instance identified by the id. +1251 * @param id {object} the object used to store a sound in the audioCache. +1252 * +1253 * @return {HTMLElement|null} the value from audioManager.loop +1254 */ +1255 audioLoop : function(id) { +1256 return this.audioManager.loop(id); 1257 }, -1258 isSoundEffectsEnabled : function() { -1259 return this.audioManager.isSoundEffectsEnabled(); +1258 endSound : function() { +1259 return this.audioManager.endSound(); 1260 }, -1261 /** -1262 * Removes Director's scenes. -1263 */ -1264 emptyScenes : function() { -1265 this.scenes = []; +1261 setSoundEffectsEnabled : function(enabled) { +1262 return this.audioManager.setSoundEffectsEnabled(enabled); +1263 }, +1264 setMusicEnabled : function(enabled) { +1265 return this.audioManager.setMusicEnabled(enabled); 1266 }, -1267 /** -1268 * Adds an scene to this Director. -1269 * @param scene {CAAT.Scene} a scene object. -1270 */ -1271 addChild : function(scene) { -1272 scene.parent = this; -1273 this.childrenList.push(scene); -1274 }, -1275 /** -1276 * @Deprecated use CAAT.loop instead. -1277 * @param fps -1278 * @param callback -1279 * @param callback2 -1280 */ -1281 loop : function(fps,callback,callback2) { -1282 if ( callback2 ) { -1283 this.onRenderStart= callback; -1284 this.onRenderEnd= callback2; -1285 } else if (callback) { -1286 this.onRenderEnd= callback; -1287 } -1288 CAAT.loop(); -1289 }, -1290 /** -1291 * Starts the director animation.If no scene is explicitly selected, the current Scene will -1292 * be the first scene added to the Director. -1293 * <p> -1294 * The fps parameter will set the animation quality. Higher values, -1295 * means CAAT will try to render more frames in the same second (at the -1296 * expense of cpu power at least until hardware accelerated canvas rendering -1297 * context are available). A value of 60 is a high frame rate and should not be exceeded. -1298 * -1299 * @param fps {number} integer value indicating the target frames per second to run -1300 * the animation at. -1301 */ -1302 renderFrame : function(fps, callback) { -1303 var t = new Date().getTime(), -1304 delta = t - this.timeline; -1305 -1306 /* -1307 check for massive frame time. if for example the current browser tab is minified or taken out of -1308 foreground, the system will account for a bit time interval. minify that impact by lowering down -1309 the elapsed time (virtual timelines FTW) -1310 */ -1311 if ( delta > 500 ) { -1312 delta= 500; -1313 } -1314 -1315 if ( this.onRenderStart ) { -1316 this.onRenderStart(delta); -1317 } -1318 -1319 this.render(delta); -1320 -1321 if ( this.debugInfo ) { -1322 this.debugInfo(this.statistics); -1323 } -1324 -1325 this.timeline = t; +1267 isMusicEnabled : function() { +1268 return this.audioManager.isMusicEnabled(); +1269 }, +1270 isSoundEffectsEnabled : function() { +1271 return this.audioManager.isSoundEffectsEnabled(); +1272 }, +1273 /** +1274 * Removes Director's scenes. +1275 */ +1276 emptyScenes : function() { +1277 this.scenes = []; +1278 }, +1279 /** +1280 * Adds an scene to this Director. +1281 * @param scene {CAAT.Scene} a scene object. +1282 */ +1283 addChild : function(scene) { +1284 scene.parent = this; +1285 this.childrenList.push(scene); +1286 }, +1287 /** +1288 * @Deprecated use CAAT.loop instead. +1289 * @param fps +1290 * @param callback +1291 * @param callback2 +1292 */ +1293 loop : function(fps,callback,callback2) { +1294 if ( callback2 ) { +1295 this.onRenderStart= callback; +1296 this.onRenderEnd= callback2; +1297 } else if (callback) { +1298 this.onRenderEnd= callback; +1299 } +1300 CAAT.loop(); +1301 }, +1302 /** +1303 * Starts the director animation.If no scene is explicitly selected, the current Scene will +1304 * be the first scene added to the Director. +1305 * <p> +1306 * The fps parameter will set the animation quality. Higher values, +1307 * means CAAT will try to render more frames in the same second (at the +1308 * expense of cpu power at least until hardware accelerated canvas rendering +1309 * context are available). A value of 60 is a high frame rate and should not be exceeded. +1310 * +1311 * @param fps {number} integer value indicating the target frames per second to run +1312 * the animation at. +1313 */ +1314 renderFrame : function(fps, callback) { +1315 var t = new Date().getTime(), +1316 delta = t - this.timeline; +1317 +1318 /* +1319 check for massive frame time. if for example the current browser tab is minified or taken out of +1320 foreground, the system will account for a bit time interval. minify that impact by lowering down +1321 the elapsed time (virtual timelines FTW) +1322 */ +1323 if ( delta > 500 ) { +1324 delta= 500; +1325 } 1326 -1327 if (this.onRenderEnd) { -1328 this.onRenderEnd(delta); +1327 if ( this.onRenderStart ) { +1328 this.onRenderStart(delta); 1329 } -1330 }, -1331 endLoop : function () { -1332 }, -1333 /** -1334 * This method states whether the director must clear background before rendering -1335 * each frame. -1336 * -1337 * The clearing method could be: -1338 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. -1339 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled -1340 * will have their areas redrawn. -1341 * + CAAT.Director.CLEAR_NONE. clears nothing. -1342 * -1343 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} -1344 * @return this. -1345 */ -1346 setClear : function(clear) { -1347 this.clear = clear; -1348 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { -1349 this.dirtyRectsEnabled= true; -1350 } -1351 return this; -1352 }, -1353 /** -1354 * Get this Director's AudioManager instance. -1355 * @return {CAAT.AudioManager} the AudioManager instance. -1356 */ -1357 getAudioManager : function() { -1358 return this.audioManager; -1359 }, -1360 /** -1361 * Acculumate dom elements position to properly offset on-screen mouse/touch events. -1362 * @param node -1363 */ -1364 cumulateOffset : function(node, parent, prop) { -1365 var left= prop+'Left'; -1366 var top= prop+'Top'; -1367 var x=0, y=0, style; -1368 -1369 while( navigator.browser!=='iOS' && node && node.style ) { -1370 if ( node.currentStyle ) { -1371 style= node.currentStyle['position']; -1372 } else { -1373 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); -1374 style= style ? style.getPropertyValue('position') : null; -1375 } -1376 -1377 // if (!/^(relative|absolute|fixed)$/.test(style)) { -1378 if (!/^(fixed)$/.test(style)) { -1379 x += node[left]; -1380 y+= node[top]; -1381 node = node[parent]; -1382 } else { -1383 break; -1384 } -1385 } -1386 -1387 return { -1388 x: x, -1389 y: y, -1390 style: style -1391 }; -1392 }, -1393 getOffset : function( node ) { -1394 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); -1395 if ( res.style==='fixed' ) { -1396 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); -1397 return { -1398 x: res.x + res2.x, -1399 y: res.y + res2.y -1400 }; -1401 } -1402 -1403 return { -1404 x: res.x, -1405 y: res.y -1406 }; -1407 }, -1408 /** -1409 * Normalize input event coordinates to be related to (0,0) canvas position. -1410 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. -1411 * @param e {MouseEvent} a mouse event from an input event. -1412 */ -1413 getCanvasCoord : function(point, e) { +1330 +1331 this.render(delta); +1332 +1333 if ( this.debugInfo ) { +1334 this.debugInfo(this.statistics); +1335 } +1336 +1337 this.timeline = t; +1338 +1339 if (this.onRenderEnd) { +1340 this.onRenderEnd(delta); +1341 } +1342 }, +1343 endLoop : function () { +1344 }, +1345 /** +1346 * This method states whether the director must clear background before rendering +1347 * each frame. +1348 * +1349 * The clearing method could be: +1350 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. +1351 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled +1352 * will have their areas redrawn. +1353 * + CAAT.Director.CLEAR_NONE. clears nothing. +1354 * +1355 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} +1356 * @return this. +1357 */ +1358 setClear : function(clear) { +1359 this.clear = clear; +1360 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { +1361 this.dirtyRectsEnabled= true; +1362 } +1363 return this; +1364 }, +1365 /** +1366 * Get this Director's AudioManager instance. +1367 * @return {CAAT.AudioManager} the AudioManager instance. +1368 */ +1369 getAudioManager : function() { +1370 return this.audioManager; +1371 }, +1372 /** +1373 * Acculumate dom elements position to properly offset on-screen mouse/touch events. +1374 * @param node +1375 */ +1376 cumulateOffset : function(node, parent, prop) { +1377 var left= prop+'Left'; +1378 var top= prop+'Top'; +1379 var x=0, y=0, style; +1380 +1381 while( navigator.browser!=='iOS' && node && node.style ) { +1382 if ( node.currentStyle ) { +1383 style= node.currentStyle['position']; +1384 } else { +1385 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); +1386 style= style ? style.getPropertyValue('position') : null; +1387 } +1388 +1389 // if (!/^(relative|absolute|fixed)$/.test(style)) { +1390 if (!/^(fixed)$/.test(style)) { +1391 x += node[left]; +1392 y+= node[top]; +1393 node = node[parent]; +1394 } else { +1395 break; +1396 } +1397 } +1398 +1399 return { +1400 x: x, +1401 y: y, +1402 style: style +1403 }; +1404 }, +1405 getOffset : function( node ) { +1406 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); +1407 if ( res.style==='fixed' ) { +1408 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); +1409 return { +1410 x: res.x + res2.x, +1411 y: res.y + res2.y +1412 }; +1413 } 1414 -1415 var posx = 0; -1416 var posy = 0; -1417 if (!e) e = window.event; -1418 -1419 if (e.pageX || e.pageY) { -1420 posx = e.pageX; -1421 posy = e.pageY; -1422 } -1423 else if (e.clientX || e.clientY) { -1424 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; -1425 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; -1426 } -1427 -1428 var offset= this.getOffset(e.target); -1429 -1430 posx-= offset.x; -1431 posy-= offset.y; -1432 -1433 ////////////// -1434 // transformar coordenada inversamente con affine transform de director. -1435 -1436 var pt= new CAAT.Point( posx, posy ); -1437 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); -1438 this.modelViewMatrixI.transformCoord(pt); -1439 posx= pt.x; -1440 posy= pt.y +1415 return { +1416 x: res.x, +1417 y: res.y +1418 }; +1419 }, +1420 /** +1421 * Normalize input event coordinates to be related to (0,0) canvas position. +1422 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. +1423 * @param e {MouseEvent} a mouse event from an input event. +1424 */ +1425 getCanvasCoord : function(point, e) { +1426 +1427 var posx = 0; +1428 var posy = 0; +1429 if (!e) e = window.event; +1430 +1431 if (e.pageX || e.pageY) { +1432 posx = e.pageX; +1433 posy = e.pageY; +1434 } +1435 else if (e.clientX || e.clientY) { +1436 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; +1437 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; +1438 } +1439 +1440 var offset= this.getOffset(e.target); 1441 -1442 point.set(posx, posy); -1443 this.screenMousePoint.set(posx, posy); +1442 posx-= offset.x; +1443 posy-= offset.y; 1444 -1445 }, -1446 -1447 __mouseDownHandler : function(e) { -1448 -1449 /* -1450 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no -1451 button was presses. Then, send a mouseUp for the previos actor, and return; -1452 */ -1453 if ( this.dragging && this.lastSelectedActor ) { -1454 this.__mouseUpHandler(e); -1455 return; -1456 } -1457 -1458 this.getCanvasCoord(this.mousePoint, e); -1459 this.isMouseDown = true; -1460 var lactor = this.findActorAtPosition(this.mousePoint); -1461 -1462 if (null !== lactor) { -1463 -1464 var pos = lactor.viewToModel( -1465 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1466 -1467 lactor.mouseDown( -1468 new CAAT.MouseEvent().init( -1469 pos.x, -1470 pos.y, -1471 e, -1472 lactor, -1473 new CAAT.Point( -1474 this.screenMousePoint.x, -1475 this.screenMousePoint.y ))); -1476 } -1477 -1478 this.lastSelectedActor= lactor; -1479 }, -1480 -1481 __mouseUpHandler : function(e) { -1482 -1483 this.isMouseDown = false; -1484 this.getCanvasCoord(this.mousePoint, e); -1485 -1486 var pos= null; -1487 var lactor= this.lastSelectedActor; -1488 -1489 if (null !== lactor) { -1490 pos = lactor.viewToModel( -1491 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1492 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { -1493 lactor.actionPerformed(e) -1494 } -1495 -1496 lactor.mouseUp( -1497 new CAAT.MouseEvent().init( -1498 pos.x, -1499 pos.y, -1500 e, -1501 lactor, -1502 this.screenMousePoint, -1503 this.currentScene.time)); -1504 } -1505 -1506 if (!this.dragging && null !== lactor) { -1507 if (lactor.contains(pos.x, pos.y)) { -1508 lactor.mouseClick( -1509 new CAAT.MouseEvent().init( -1510 pos.x, -1511 pos.y, -1512 e, -1513 lactor, -1514 this.screenMousePoint, -1515 this.currentScene.time)); -1516 } -1517 } -1518 -1519 this.dragging = false; -1520 this.in_= false; -1521 // CAAT.setCursor('default'); -1522 }, -1523 -1524 __mouseMoveHandler : function(e) { -1525 this.getCanvasCoord(this.mousePoint, e); -1526 -1527 var lactor; -1528 var pos; -1529 -1530 // drag -1531 -1532 if (this.isMouseDown && null !== this.lastSelectedActor) { -1533 /* -1534 // check for mouse move threshold. -1535 if (!this.dragging) { -1536 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && -1537 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { -1538 return; -1539 } -1540 } -1541 */ -1542 +1445 ////////////// +1446 // transformar coordenada inversamente con affine transform de director. +1447 +1448 var pt= new CAAT.Point( posx, posy ); +1449 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); +1450 this.modelViewMatrixI.transformCoord(pt); +1451 posx= pt.x; +1452 posy= pt.y +1453 +1454 point.set(posx, posy); +1455 this.screenMousePoint.set(posx, posy); +1456 +1457 }, +1458 +1459 __mouseDownHandler : function(e) { +1460 +1461 /* +1462 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no +1463 button was presses. Then, send a mouseUp for the previos actor, and return; +1464 */ +1465 if ( this.dragging && this.lastSelectedActor ) { +1466 this.__mouseUpHandler(e); +1467 return; +1468 } +1469 +1470 this.getCanvasCoord(this.mousePoint, e); +1471 this.isMouseDown = true; +1472 var lactor = this.findActorAtPosition(this.mousePoint); +1473 +1474 if (null !== lactor) { +1475 +1476 var pos = lactor.viewToModel( +1477 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1478 +1479 lactor.mouseDown( +1480 new CAAT.MouseEvent().init( +1481 pos.x, +1482 pos.y, +1483 e, +1484 lactor, +1485 new CAAT.Point( +1486 this.screenMousePoint.x, +1487 this.screenMousePoint.y ))); +1488 } +1489 +1490 this.lastSelectedActor= lactor; +1491 }, +1492 +1493 __mouseUpHandler : function(e) { +1494 +1495 this.isMouseDown = false; +1496 this.getCanvasCoord(this.mousePoint, e); +1497 +1498 var pos= null; +1499 var lactor= this.lastSelectedActor; +1500 +1501 if (null !== lactor) { +1502 pos = lactor.viewToModel( +1503 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1504 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { +1505 lactor.actionPerformed(e) +1506 } +1507 +1508 lactor.mouseUp( +1509 new CAAT.MouseEvent().init( +1510 pos.x, +1511 pos.y, +1512 e, +1513 lactor, +1514 this.screenMousePoint, +1515 this.currentScene.time)); +1516 } +1517 +1518 if (!this.dragging && null !== lactor) { +1519 if (lactor.contains(pos.x, pos.y)) { +1520 lactor.mouseClick( +1521 new CAAT.MouseEvent().init( +1522 pos.x, +1523 pos.y, +1524 e, +1525 lactor, +1526 this.screenMousePoint, +1527 this.currentScene.time)); +1528 } +1529 } +1530 +1531 this.dragging = false; +1532 this.in_= false; +1533 // CAAT.setCursor('default'); +1534 }, +1535 +1536 __mouseMoveHandler : function(e) { +1537 this.getCanvasCoord(this.mousePoint, e); +1538 +1539 var lactor; +1540 var pos; +1541 +1542 // drag 1543 -1544 lactor = this.lastSelectedActor; -1545 pos = lactor.viewToModel( -1546 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1547 -1548 this.dragging = true; -1549 -1550 var px= lactor.x; -1551 var py= lactor.y; -1552 lactor.mouseDrag( -1553 new CAAT.MouseEvent().init( -1554 pos.x, -1555 pos.y, -1556 e, -1557 lactor, -1558 new CAAT.Point( -1559 this.screenMousePoint.x, -1560 this.screenMousePoint.y), -1561 this.currentScene.time)); -1562 -1563 this.prevMousePoint.x= pos.x; -1564 this.prevMousePoint.y= pos.y; -1565 -1566 /** -1567 * Element has not moved after drag, so treat it as a button. -1568 */ -1569 if ( px===lactor.x && py===lactor.y ) { -1570 -1571 var contains= lactor.contains(pos.x, pos.y); -1572 -1573 if (this.in_ && !contains) { -1574 lactor.mouseExit( -1575 new CAAT.MouseEvent().init( -1576 pos.x, -1577 pos.y, -1578 e, -1579 lactor, -1580 this.screenMousePoint, -1581 this.currentScene.time)); -1582 this.in_ = false; -1583 } +1544 if (this.isMouseDown && null !== this.lastSelectedActor) { +1545 /* +1546 // check for mouse move threshold. +1547 if (!this.dragging) { +1548 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && +1549 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { +1550 return; +1551 } +1552 } +1553 */ +1554 +1555 +1556 lactor = this.lastSelectedActor; +1557 pos = lactor.viewToModel( +1558 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1559 +1560 this.dragging = true; +1561 +1562 var px= lactor.x; +1563 var py= lactor.y; +1564 lactor.mouseDrag( +1565 new CAAT.MouseEvent().init( +1566 pos.x, +1567 pos.y, +1568 e, +1569 lactor, +1570 new CAAT.Point( +1571 this.screenMousePoint.x, +1572 this.screenMousePoint.y), +1573 this.currentScene.time)); +1574 +1575 this.prevMousePoint.x= pos.x; +1576 this.prevMousePoint.y= pos.y; +1577 +1578 /** +1579 * Element has not moved after drag, so treat it as a button. +1580 */ +1581 if ( px===lactor.x && py===lactor.y ) { +1582 +1583 var contains= lactor.contains(pos.x, pos.y); 1584 -1585 if (!this.in_ && contains ) { -1586 lactor.mouseEnter( +1585 if (this.in_ && !contains) { +1586 lactor.mouseExit( 1587 new CAAT.MouseEvent().init( 1588 pos.x, 1589 pos.y, @@ -1598,426 +1598,438 @@ 1591 lactor, 1592 this.screenMousePoint, 1593 this.currentScene.time)); -1594 this.in_ = true; +1594 this.in_ = false; 1595 } -1596 } -1597 -1598 return; -1599 } -1600 -1601 // mouse move. -1602 this.in_= true; -1603 -1604 lactor = this.findActorAtPosition(this.mousePoint); -1605 -1606 // cambiamos de actor. -1607 if (lactor !== this.lastSelectedActor) { -1608 if (null !== this.lastSelectedActor) { +1596 +1597 if (!this.in_ && contains ) { +1598 lactor.mouseEnter( +1599 new CAAT.MouseEvent().init( +1600 pos.x, +1601 pos.y, +1602 e, +1603 lactor, +1604 this.screenMousePoint, +1605 this.currentScene.time)); +1606 this.in_ = true; +1607 } +1608 } 1609 -1610 pos = this.lastSelectedActor.viewToModel( -1611 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1610 return; +1611 } 1612 -1613 this.lastSelectedActor.mouseExit( -1614 new CAAT.MouseEvent().init( -1615 pos.x, -1616 pos.y, -1617 e, -1618 this.lastSelectedActor, -1619 this.screenMousePoint, -1620 this.currentScene.time)); -1621 } -1622 -1623 if (null !== lactor) { -1624 pos = lactor.viewToModel( -1625 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1626 -1627 lactor.mouseEnter( -1628 new CAAT.MouseEvent().init( -1629 pos.x, -1630 pos.y, -1631 e, -1632 lactor, -1633 this.screenMousePoint, -1634 this.currentScene.time)); -1635 } -1636 } -1637 -1638 pos = lactor.viewToModel( -1639 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1640 -1641 if (null !== lactor) { -1642 -1643 lactor.mouseMove( -1644 new CAAT.MouseEvent().init( -1645 pos.x, -1646 pos.y, -1647 e, -1648 lactor, -1649 this.screenMousePoint, -1650 this.currentScene.time)); -1651 } +1613 // mouse move. +1614 this.in_= true; +1615 +1616 lactor = this.findActorAtPosition(this.mousePoint); +1617 +1618 // cambiamos de actor. +1619 if (lactor !== this.lastSelectedActor) { +1620 if (null !== this.lastSelectedActor) { +1621 +1622 pos = this.lastSelectedActor.viewToModel( +1623 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1624 +1625 this.lastSelectedActor.mouseExit( +1626 new CAAT.MouseEvent().init( +1627 pos.x, +1628 pos.y, +1629 e, +1630 this.lastSelectedActor, +1631 this.screenMousePoint, +1632 this.currentScene.time)); +1633 } +1634 +1635 if (null !== lactor) { +1636 pos = lactor.viewToModel( +1637 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1638 +1639 lactor.mouseEnter( +1640 new CAAT.MouseEvent().init( +1641 pos.x, +1642 pos.y, +1643 e, +1644 lactor, +1645 this.screenMousePoint, +1646 this.currentScene.time)); +1647 } +1648 } +1649 +1650 pos = lactor.viewToModel( +1651 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); 1652 -1653 this.lastSelectedActor = lactor; -1654 }, -1655 -1656 __mouseOutHandler : function(e) { -1657 -1658 if (null !== this.lastSelectedActor ) { -1659 -1660 this.getCanvasCoord(this.mousePoint, e); -1661 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); -1662 this.lastSelectedActor.viewToModel(pos); -1663 -1664 var ev= new CAAT.MouseEvent().init( -1665 pos.x, -1666 pos.y, -1667 e, -1668 this.lastSelectedActor, -1669 this.screenMousePoint, -1670 this.currentScene.time); +1653 if (null !== lactor) { +1654 +1655 lactor.mouseMove( +1656 new CAAT.MouseEvent().init( +1657 pos.x, +1658 pos.y, +1659 e, +1660 lactor, +1661 this.screenMousePoint, +1662 this.currentScene.time)); +1663 } +1664 +1665 this.lastSelectedActor = lactor; +1666 }, +1667 +1668 __mouseOutHandler : function(e) { +1669 +1670 if (null !== this.lastSelectedActor ) { 1671 -1672 this.lastSelectedActor.mouseExit(ev); -1673 this.lastSelectedActor.mouseOut(ev); -1674 -1675 if ( !this.dragging ) { -1676 this.lastSelectedActor = null; -1677 } -1678 } else { -1679 this.isMouseDown = false; -1680 this.in_ = false; -1681 } -1682 -1683 }, -1684 -1685 __mouseOverHandler : function(e) { +1672 this.getCanvasCoord(this.mousePoint, e); +1673 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); +1674 this.lastSelectedActor.viewToModel(pos); +1675 +1676 var ev= new CAAT.MouseEvent().init( +1677 pos.x, +1678 pos.y, +1679 e, +1680 this.lastSelectedActor, +1681 this.screenMousePoint, +1682 this.currentScene.time); +1683 +1684 this.lastSelectedActor.mouseExit(ev); +1685 this.lastSelectedActor.mouseOut(ev); 1686 -1687 var lactor; -1688 var pos, ev; -1689 this.getCanvasCoord(this.mousePoint, e); -1690 -1691 if ( null==this.lastSelectedActor ) { -1692 lactor= this.findActorAtPosition( this.mousePoint ); -1693 -1694 if (null !== lactor) { -1695 -1696 pos = lactor.viewToModel( -1697 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1687 if ( !this.dragging ) { +1688 this.lastSelectedActor = null; +1689 } +1690 } else { +1691 this.isMouseDown = false; +1692 this.in_ = false; +1693 } +1694 +1695 }, +1696 +1697 __mouseOverHandler : function(e) { 1698 -1699 ev= new CAAT.MouseEvent().init( -1700 pos.x, -1701 pos.y, -1702 e, -1703 lactor, -1704 this.screenMousePoint, -1705 this.currentScene.time); -1706 -1707 lactor.mouseOver(ev); -1708 lactor.mouseEnter(ev); -1709 } +1699 var lactor; +1700 var pos, ev; +1701 this.getCanvasCoord(this.mousePoint, e); +1702 +1703 if ( null==this.lastSelectedActor ) { +1704 lactor= this.findActorAtPosition( this.mousePoint ); +1705 +1706 if (null !== lactor) { +1707 +1708 pos = lactor.viewToModel( +1709 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); 1710 -1711 this.lastSelectedActor= lactor; -1712 } else { -1713 lactor= this.lastSelectedActor; -1714 pos = lactor.viewToModel( -1715 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1716 -1717 ev= new CAAT.MouseEvent().init( -1718 pos.x, -1719 pos.y, -1720 e, -1721 lactor, -1722 this.screenMousePoint, -1723 this.currentScene.time); -1724 -1725 lactor.mouseOver(ev); -1726 lactor.mouseEnter(ev); -1727 -1728 } -1729 }, -1730 -1731 __mouseDBLClickHandler : function(e) { -1732 -1733 this.getCanvasCoord(this.mousePoint, e); -1734 if (null !== this.lastSelectedActor) { -1735 /* -1736 var pos = this.lastSelectedActor.viewToModel( -1737 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1738 */ -1739 this.lastSelectedActor.mouseDblClick( -1740 new CAAT.MouseEvent().init( -1741 this.mousePoint.x, -1742 this.mousePoint.y, -1743 e, -1744 this.lastSelectedActor, -1745 this.screenMousePoint, -1746 this.currentScene.time)); -1747 } -1748 }, -1749 -1750 /** -1751 * Same as mouseDown but not preventing event. -1752 * Will only take care of first touch. -1753 * @param e -1754 */ -1755 __touchStartHandler : function(e) { -1756 -1757 e.preventDefault(); -1758 e= e.targetTouches[0] -1759 this.__mouseDownHandler(e); +1711 ev= new CAAT.MouseEvent().init( +1712 pos.x, +1713 pos.y, +1714 e, +1715 lactor, +1716 this.screenMousePoint, +1717 this.currentScene.time); +1718 +1719 lactor.mouseOver(ev); +1720 lactor.mouseEnter(ev); +1721 } +1722 +1723 this.lastSelectedActor= lactor; +1724 } else { +1725 lactor= this.lastSelectedActor; +1726 pos = lactor.viewToModel( +1727 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1728 +1729 ev= new CAAT.MouseEvent().init( +1730 pos.x, +1731 pos.y, +1732 e, +1733 lactor, +1734 this.screenMousePoint, +1735 this.currentScene.time); +1736 +1737 lactor.mouseOver(ev); +1738 lactor.mouseEnter(ev); +1739 +1740 } +1741 }, +1742 +1743 __mouseDBLClickHandler : function(e) { +1744 +1745 this.getCanvasCoord(this.mousePoint, e); +1746 if (null !== this.lastSelectedActor) { +1747 /* +1748 var pos = this.lastSelectedActor.viewToModel( +1749 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1750 */ +1751 this.lastSelectedActor.mouseDblClick( +1752 new CAAT.MouseEvent().init( +1753 this.mousePoint.x, +1754 this.mousePoint.y, +1755 e, +1756 this.lastSelectedActor, +1757 this.screenMousePoint, +1758 this.currentScene.time)); +1759 } 1760 }, 1761 -1762 __touchEndHandler : function(e) { -1763 -1764 e.preventDefault(); -1765 e= e.changedTouches[0]; -1766 this.__mouseUpHandler(e); -1767 }, +1762 /** +1763 * Same as mouseDown but not preventing event. +1764 * Will only take care of first touch. +1765 * @param e +1766 */ +1767 __touchStartHandler : function(e) { 1768 -1769 __touchMoveHandler : function(e) { -1770 -1771 e.preventDefault(); -1772 -1773 if ( this.gesturing ) { -1774 return; -1775 } -1776 -1777 for( var i=0; i<e.targetTouches.length; i++ ) { -1778 if ( !i ) { -1779 this.__mouseMoveHandler(e.targetTouches[i]); -1780 } -1781 } -1782 }, -1783 -1784 __gestureStart : function( scale, rotation ) { -1785 this.gesturing= true; -1786 this.__gestureRotation= this.lastSelectedActor.rotationAngle; -1787 this.__gestureSX= this.lastSelectedActor.scaleX - 1; -1788 this.__gestureSY= this.lastSelectedActor.scaleY - 1; -1789 }, -1790 -1791 __gestureChange : function( scale, rotation ) { -1792 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { -1793 return; -1794 } +1769 e.preventDefault(); +1770 e= e.targetTouches[0] +1771 this.__mouseDownHandler(e); +1772 }, +1773 +1774 __touchEndHandler : function(e) { +1775 +1776 e.preventDefault(); +1777 e= e.changedTouches[0]; +1778 this.__mouseUpHandler(e); +1779 }, +1780 +1781 __touchMoveHandler : function(e) { +1782 +1783 e.preventDefault(); +1784 +1785 if ( this.gesturing ) { +1786 return; +1787 } +1788 +1789 for( var i=0; i<e.targetTouches.length; i++ ) { +1790 if ( !i ) { +1791 this.__mouseMoveHandler(e.targetTouches[i]); +1792 } +1793 } +1794 }, 1795 -1796 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { -1797 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); -1798 -1799 this.lastSelectedActor.setScale( -1800 this.__gestureSX + scale, -1801 this.__gestureSY + scale ); -1802 } -1803 -1804 }, -1805 -1806 __gestureEnd : function( scale, rotation ) { -1807 this.gesturing= false; -1808 this.__gestureRotation= 0; -1809 this.__gestureScale= 0; -1810 }, -1811 -1812 addHandlers: function(canvas) { -1813 -1814 var me= this; +1796 __gestureStart : function( scale, rotation ) { +1797 this.gesturing= true; +1798 this.__gestureRotation= this.lastSelectedActor.rotationAngle; +1799 this.__gestureSX= this.lastSelectedActor.scaleX - 1; +1800 this.__gestureSY= this.lastSelectedActor.scaleY - 1; +1801 }, +1802 +1803 __gestureChange : function( scale, rotation ) { +1804 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { +1805 return; +1806 } +1807 +1808 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { +1809 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); +1810 +1811 this.lastSelectedActor.setScale( +1812 this.__gestureSX + scale, +1813 this.__gestureSY + scale ); +1814 } 1815 -1816 canvas.addEventListener('mouseup', function(e) { -1817 e.preventDefault(); -1818 me.__mouseUpHandler(e); -1819 }, false ); -1820 -1821 canvas.addEventListener('mousedown', function(e) { -1822 e.preventDefault(); -1823 me.__mouseDownHandler(e); -1824 }, false ); +1816 }, +1817 +1818 __gestureEnd : function( scale, rotation ) { +1819 this.gesturing= false; +1820 this.__gestureRotation= 0; +1821 this.__gestureScale= 0; +1822 }, +1823 +1824 addHandlers: function(canvas) { 1825 -1826 canvas.addEventListener('mouseover',function(e) { -1827 e.preventDefault(); -1828 me.__mouseOverHandler(e); -1829 }, false); -1830 -1831 canvas.addEventListener('mouseout',function(e) { -1832 e.preventDefault(); -1833 me.__mouseOutHandler(e); -1834 }, false); -1835 -1836 canvas.addEventListener('mousemove', -1837 function(e) { -1838 e.preventDefault(); -1839 me.__mouseMoveHandler(e); -1840 }, -1841 false); +1826 var me= this; +1827 +1828 canvas.addEventListener('mouseup', function(e) { +1829 e.preventDefault(); +1830 me.__mouseUpHandler(e); +1831 }, false ); +1832 +1833 canvas.addEventListener('mousedown', function(e) { +1834 e.preventDefault(); +1835 me.__mouseDownHandler(e); +1836 }, false ); +1837 +1838 canvas.addEventListener('mouseover',function(e) { +1839 e.preventDefault(); +1840 me.__mouseOverHandler(e); +1841 }, false); 1842 -1843 canvas.addEventListener("dblclick", function(e) { +1843 canvas.addEventListener('mouseout',function(e) { 1844 e.preventDefault(); -1845 me.__mouseDBLClickHandler(e); +1845 me.__mouseOutHandler(e); 1846 }, false); 1847 -1848 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); -1849 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); -1850 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); -1851 canvas.addEventListener("gesturestart", function(e) { -1852 e.preventDefault(); -1853 me.__gestureStart( e.scale, e.rotation ); -1854 }, false ); -1855 canvas.addEventListener("gestureend", function(e) { +1848 canvas.addEventListener('mousemove', +1849 function(e) { +1850 e.preventDefault(); +1851 me.__mouseMoveHandler(e); +1852 }, +1853 false); +1854 +1855 canvas.addEventListener("dblclick", function(e) { 1856 e.preventDefault(); -1857 me.__gestureEnd( e.scale, e.rotation ); -1858 }, false ); -1859 canvas.addEventListener("gesturechange", function(e) { -1860 e.preventDefault(); -1861 me.__gestureChange( e.scale, e.rotation ); -1862 }, false ); -1863 }, -1864 -1865 enableEvents : function( onElement ) { -1866 CAAT.RegisterDirector(this); -1867 this.in_ = false; -1868 this.createEventHandler( onElement ); -1869 }, -1870 -1871 createEventHandler : function( onElement ) { -1872 //var canvas= this.canvas; -1873 this.in_ = false; -1874 //this.addHandlers(canvas); -1875 this.addHandlers( onElement ); -1876 } -1877 }; -1878 -1879 -1880 if (CAAT.__CSS__) { -1881 -1882 CAAT.Director.prototype.clip= true; -1883 CAAT.Director.prototype.glEnabled= false; -1884 -1885 CAAT.Director.prototype.getRenderType= function() { -1886 return 'CSS'; -1887 }; -1888 -1889 CAAT.Director.prototype.setScaleProportional= function(w,h) { +1857 me.__mouseDBLClickHandler(e); +1858 }, false); +1859 +1860 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); +1861 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); +1862 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); +1863 canvas.addEventListener("gesturestart", function(e) { +1864 e.preventDefault(); +1865 me.__gestureStart( e.scale, e.rotation ); +1866 }, false ); +1867 canvas.addEventListener("gestureend", function(e) { +1868 e.preventDefault(); +1869 me.__gestureEnd( e.scale, e.rotation ); +1870 }, false ); +1871 canvas.addEventListener("gesturechange", function(e) { +1872 e.preventDefault(); +1873 me.__gestureChange( e.scale, e.rotation ); +1874 }, false ); +1875 }, +1876 +1877 enableEvents : function( onElement ) { +1878 CAAT.RegisterDirector(this); +1879 this.in_ = false; +1880 this.createEventHandler( onElement ); +1881 }, +1882 +1883 createEventHandler : function( onElement ) { +1884 //var canvas= this.canvas; +1885 this.in_ = false; +1886 //this.addHandlers(canvas); +1887 this.addHandlers( onElement ); +1888 } +1889 }; 1890 -1891 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); -1892 this.setScaleAnchored( factor, factor, 0, 0 ); +1891 +1892 if (CAAT.__CSS__) { 1893 -1894 this.eventHandler.style.width= ''+this.referenceWidth +'px'; -1895 this.eventHandler.style.height= ''+this.referenceHeight+'px'; -1896 }; -1897 -1898 CAAT.Director.prototype.setBounds= function(x, y, w, h) { -1899 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); -1900 for (var i = 0; i < this.scenes.length; i++) { -1901 this.scenes[i].setBounds(0, 0, w, h); -1902 } -1903 this.eventHandler.style.width= w+'px'; -1904 this.eventHandler.style.height= h+'px'; +1894 CAAT.Director.prototype.clip= true; +1895 CAAT.Director.prototype.glEnabled= false; +1896 +1897 CAAT.Director.prototype.getRenderType= function() { +1898 return 'CSS'; +1899 }; +1900 +1901 CAAT.Director.prototype.setScaleProportional= function(w,h) { +1902 +1903 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); +1904 this.setScaleAnchored( factor, factor, 0, 0 ); 1905 -1906 return this; -1907 }; -1908 -1909 /** -1910 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most -1911 * div in the document hierarchy (z-index 999999). -1912 * @param width -1913 * @param height -1914 * @param domElement -1915 * @param proxy -1916 */ -1917 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { -1918 -1919 this.timeline = new Date().getTime(); -1920 this.domElement= domElement; -1921 this.style('position','absolute'); -1922 this.style('width',''+width+'px'); -1923 this.style('height',''+height+'px'); -1924 this.style('overflow', 'hidden' ); -1925 -1926 this.enableEvents(domElement); -1927 -1928 this.setBounds(0, 0, width, height); -1929 -1930 this.checkDebug(); -1931 return this; -1932 }; -1933 -1934 CAAT.Director.prototype.render= function(time) { -1935 -1936 this.time += time; -1937 this.animate(this,time); -1938 -1939 /** -1940 * draw director active scenes. -1941 */ -1942 var i, l, tt; -1943 -1944 if ( CAAT.DEBUG ) { -1945 this.resetStats(); -1946 } +1906 this.eventHandler.style.width= ''+this.referenceWidth +'px'; +1907 this.eventHandler.style.height= ''+this.referenceHeight+'px'; +1908 }; +1909 +1910 CAAT.Director.prototype.setBounds= function(x, y, w, h) { +1911 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); +1912 for (var i = 0; i < this.scenes.length; i++) { +1913 this.scenes[i].setBounds(0, 0, w, h); +1914 } +1915 this.eventHandler.style.width= w+'px'; +1916 this.eventHandler.style.height= h+'px'; +1917 +1918 return this; +1919 }; +1920 +1921 /** +1922 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most +1923 * div in the document hierarchy (z-index 999999). +1924 * @param width +1925 * @param height +1926 * @param domElement +1927 * @param proxy +1928 */ +1929 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { +1930 +1931 this.timeline = new Date().getTime(); +1932 this.domElement= domElement; +1933 this.style('position','absolute'); +1934 this.style('width',''+width+'px'); +1935 this.style('height',''+height+'px'); +1936 this.style('overflow', 'hidden' ); +1937 +1938 this.enableEvents(domElement); +1939 +1940 this.setBounds(0, 0, width, height); +1941 +1942 this.checkDebug(); +1943 return this; +1944 }; +1945 +1946 CAAT.Director.prototype.render= function(time) { 1947 -1948 for (i = 0, l=this.childrenList.length; i < l; i++) { -1949 var c= this.childrenList[i]; -1950 if (c.isInAnimationFrame(this.time)) { -1951 tt = c.time - c.start_time; -1952 if ( c.onRenderStart ) { -1953 c.onRenderStart(tt); -1954 } +1948 this.time += time; +1949 this.animate(this,time); +1950 +1951 /** +1952 * draw director active scenes. +1953 */ +1954 var i, l, tt; 1955 -1956 if ( c.onRenderEnd ) { -1957 c.onRenderEnd(tt); -1958 } +1956 if ( CAAT.DEBUG ) { +1957 this.resetStats(); +1958 } 1959 -1960 if (!c.isPaused()) { -1961 c.time += time; -1962 } -1963 -1964 if ( CAAT.DEBUG ) { -1965 this.statistics.size_total+= c.size_total; -1966 this.statistics.size_active+= c.size_active; -1967 } -1968 -1969 } -1970 } +1960 for (i = 0, l=this.childrenList.length; i < l; i++) { +1961 var c= this.childrenList[i]; +1962 if (c.isInAnimationFrame(this.time)) { +1963 tt = c.time - c.start_time; +1964 if ( c.onRenderStart ) { +1965 c.onRenderStart(tt); +1966 } +1967 +1968 if ( c.onRenderEnd ) { +1969 c.onRenderEnd(tt); +1970 } 1971 -1972 this.frameCounter++; -1973 }; -1974 -1975 CAAT.Director.prototype.addScene= function(scene) { -1976 scene.setVisible(true); -1977 scene.setBounds(0, 0, this.width, this.height); -1978 this.scenes.push(scene); -1979 scene.setEaseListener(this); -1980 if (null === this.currentScene) { -1981 this.setScene(0); +1972 if (!c.isPaused()) { +1973 c.time += time; +1974 } +1975 +1976 if ( CAAT.DEBUG ) { +1977 this.statistics.size_total+= c.size_total; +1978 this.statistics.size_active+= c.size_active; +1979 } +1980 +1981 } 1982 } 1983 -1984 this.domElement.appendChild( scene.domElement ); +1984 this.frameCounter++; 1985 }; 1986 -1987 CAAT.Director.prototype.emptyScenes= function() { -1988 this.scenes = []; -1989 this.domElement.innerHTML=''; -1990 this.createEventHandler(); -1991 }; -1992 -1993 CAAT.Director.prototype.setClear= function(clear) { -1994 return this; -1995 }; -1996 -1997 CAAT.Director.prototype.createEventHandler= function() { -1998 this.eventHandler= document.createElement('div'); -1999 this.domElement.appendChild(this.eventHandler); -2000 -2001 this.eventHandler.style.position= 'absolute'; -2002 this.eventHandler.style.left= '0'; -2003 this.eventHandler.style.top= '0'; -2004 this.eventHandler.style.zIndex= 999999; -2005 this.eventHandler.style.width= ''+this.width+'px'; -2006 this.eventHandler.style.height= ''+this.height+'px'; -2007 -2008 var canvas= this.eventHandler; -2009 this.in_ = false; -2010 -2011 this.addHandlers(canvas); -2012 }; -2013 } -2014 -2015 extend(CAAT.Director, CAAT.ActorContainer, null); -2016 })(); \ No newline at end of file +1987 CAAT.Director.prototype.addScene= function(scene) { +1988 scene.setVisible(true); +1989 scene.setBounds(0, 0, this.width, this.height); +1990 this.scenes.push(scene); +1991 scene.setEaseListener(this); +1992 if (null === this.currentScene) { +1993 this.setScene(0); +1994 } +1995 +1996 this.domElement.appendChild( scene.domElement ); +1997 }; +1998 +1999 CAAT.Director.prototype.emptyScenes= function() { +2000 this.scenes = []; +2001 this.domElement.innerHTML=''; +2002 this.createEventHandler(); +2003 }; +2004 +2005 CAAT.Director.prototype.setClear= function(clear) { +2006 return this; +2007 }; +2008 +2009 CAAT.Director.prototype.createEventHandler= function() { +2010 this.eventHandler= document.createElement('div'); +2011 this.domElement.appendChild(this.eventHandler); +2012 +2013 this.eventHandler.style.position= 'absolute'; +2014 this.eventHandler.style.left= '0'; +2015 this.eventHandler.style.top= '0'; +2016 this.eventHandler.style.zIndex= 999999; +2017 this.eventHandler.style.width= ''+this.width+'px'; +2018 this.eventHandler.style.height= ''+this.height+'px'; +2019 +2020 var canvas= this.eventHandler; +2021 this.in_ = false; +2022 +2023 this.addHandlers(canvas); +2024 }; +2025 } +2026 +2027 extend(CAAT.Director, CAAT.ActorContainer, null); +2028 })(); \ No newline at end of file diff --git a/src/model/director.js b/src/model/director.js index d483d0f4..d3044870 100644 --- a/src/model/director.js +++ b/src/model/director.js @@ -589,7 +589,7 @@ if ( this.dirtyRectsEnabled ) { ctx.beginPath(); - +ctx.rect(0,0,120,40); var dr= this.cDirtyRects; for( i=0; i