diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index d71cbe0d..ae679185 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -22,11 +22,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 208 +Version: 0.3 build: 212 Created on: DATE: 2012-02-23 -TIME: 17:03:41 +TIME: 17:37:53 */ diff --git a/build/caat-box2d.js b/build/caat-box2d.js index c5636b38..572d179f 100644 --- a/build/caat-box2d.js +++ b/build/caat-box2d.js @@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 209 +Version: 0.3 build: 213 Created on: DATE: 2012-02-23 -TIME: 17:04:10 +TIME: 17:38:27 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index d703b8f9..5495382a 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -22,15 +22,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Version: 0.3 build: 208 +Version: 0.3 build: 212 Created on: DATE: 2012-02-23 -TIME: 17:03:41 +TIME: 17:37:53 */ -var CAAT=CAAT||{};Function.prototype.bind=Function.prototype.bind||function(){var a=this,b=Array.prototype.slice.call(arguments),c=b.shift();return function(){return a.apply(c,b.concat(Array.prototype.slice.call(arguments)))}};CAAT.__CSS__=1;(function(){CAAT.BrowserDetect=function(){this.init();return this};CAAT.BrowserDetect.prototype={browser:"",version:0,OS:"",init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;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.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, +document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c= +b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a), +c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0));this.dragging=true;var e=b.x,f=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),d));this.prevMousePoint.x=c.x;this.prevMousePoint.y=c.y;if(e===b.x&&f===b.y){e=b.contains(c.x,c.y);if(this.in_&&!e)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=false;if(!this.in_&&e)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=true}}else this.in_= +true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,d))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint, +d)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time); +this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_=this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScane?this.currentScene.time: +0),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor, this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;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.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, +document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c= +b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a), +c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0));this.dragging=true;var e=b.x,f=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),d));this.prevMousePoint.x=c.x;this.prevMousePoint.y=c.y;if(e===b.x&&f===b.y){e=b.contains(c.x,c.y);if(this.in_&&!e)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=false;if(!this.in_&&e)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.in_=true}}else this.in_= +true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,d))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint, +d)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,d)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time); +this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_=this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScane?this.currentScene.time: +0),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor, this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b/User
- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 GMT+0100 (CET)
\ No newline at end of file diff --git a/documentation/jsdoc/index.html b/documentation/jsdoc/index.html index d91d1e59..4f6c0662 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 Mon Feb 20 2012 23:56:04 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 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 f05a8fbf..508edb8b 100644 --- a/documentation/jsdoc/symbols/CAAT.Actor.html +++ b/documentation/jsdoc/symbols/CAAT.Actor.html @@ -4928,7 +4928,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ActorContainer.html b/documentation/jsdoc/symbols/CAAT.ActorContainer.html index e151c7f3..fe6f22ea 100644 --- a/documentation/jsdoc/symbols/CAAT.ActorContainer.html +++ b/documentation/jsdoc/symbols/CAAT.ActorContainer.html @@ -1498,7 +1498,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.AudioManager.html b/documentation/jsdoc/symbols/CAAT.AudioManager.html index 3afe6cd1..a0525cc1 100644 --- a/documentation/jsdoc/symbols/CAAT.AudioManager.html +++ b/documentation/jsdoc/symbols/CAAT.AudioManager.html @@ -1185,7 +1185,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html index 488200ff..139e11ae 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 Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html index 9644d8c2..9e3c4232 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html index aa5180e8..64a9802c 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Bezier.html b/documentation/jsdoc/symbols/CAAT.Bezier.html index 548d9b29..c6e877eb 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CatmullRom.html b/documentation/jsdoc/symbols/CAAT.CatmullRom.html index b1d04fda..83bf2753 100644 --- a/documentation/jsdoc/symbols/CAAT.CatmullRom.html +++ b/documentation/jsdoc/symbols/CAAT.CatmullRom.html @@ -574,7 +574,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.RGB.html b/documentation/jsdoc/symbols/CAAT.Color.RGB.html index 9ecb22b7..8ea61b73 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.html b/documentation/jsdoc/symbols/CAAT.Color.html index eef6af8b..3d2ec069 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Curve.html b/documentation/jsdoc/symbols/CAAT.Curve.html index 9806aac0..5afab9e4 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CurvePath.html b/documentation/jsdoc/symbols/CAAT.CurvePath.html index d0e64d0d..36856a95 100644 --- a/documentation/jsdoc/symbols/CAAT.CurvePath.html +++ b/documentation/jsdoc/symbols/CAAT.CurvePath.html @@ -1199,7 +1199,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Director.html b/documentation/jsdoc/symbols/CAAT.Director.html index 25528fcf..5e89e694 100644 --- a/documentation/jsdoc/symbols/CAAT.Director.html +++ b/documentation/jsdoc/symbols/CAAT.Director.html @@ -4476,7 +4476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Font.html b/documentation/jsdoc/symbols/CAAT.Font.html index 12de0e19..827a762a 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 Mon Feb 20 2012 23:56:01 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMActor.html b/documentation/jsdoc/symbols/CAAT.IMActor.html index 2341ecaf..c8f6de1b 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMBump.html b/documentation/jsdoc/symbols/CAAT.IMBump.html index ba2e3f33..1a46b797 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMPlasma.html b/documentation/jsdoc/symbols/CAAT.IMPlasma.html index 426a73e2..50bbebbf 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html index 4b71a33a..65ed1322 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html index 3776cca2..e9c66993 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html index 9e1d69da..ea420bb8 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:05 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Interpolator.html b/documentation/jsdoc/symbols/CAAT.Interpolator.html index b1c436a4..ac27825d 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html index 36cf4ed5..5f2ccbd1 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.KeyEvent.html b/documentation/jsdoc/symbols/CAAT.KeyEvent.html index 12368d80..3752e1be 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.LinearPath.html b/documentation/jsdoc/symbols/CAAT.LinearPath.html index 206f41cc..dee98fca 100644 --- a/documentation/jsdoc/symbols/CAAT.LinearPath.html +++ b/documentation/jsdoc/symbols/CAAT.LinearPath.html @@ -1124,7 +1124,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Matrix3.html b/documentation/jsdoc/symbols/CAAT.Matrix3.html index e570f6f6..ace50f64 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MatrixStack.html b/documentation/jsdoc/symbols/CAAT.MatrixStack.html index e5fc7bf1..f5d07bf5 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MouseEvent.html b/documentation/jsdoc/symbols/CAAT.MouseEvent.html index a1c53278..1ad38448 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Path.html b/documentation/jsdoc/symbols/CAAT.Path.html index 7e9de627..ff59fe0b 100644 --- a/documentation/jsdoc/symbols/CAAT.Path.html +++ b/documentation/jsdoc/symbols/CAAT.Path.html @@ -3458,7 +3458,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathActor.html b/documentation/jsdoc/symbols/CAAT.PathActor.html index 9a267a06..e0fac092 100644 --- a/documentation/jsdoc/symbols/CAAT.PathActor.html +++ b/documentation/jsdoc/symbols/CAAT.PathActor.html @@ -833,7 +833,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathSegment.html b/documentation/jsdoc/symbols/CAAT.PathSegment.html index 29cf5b76..4f139532 100644 --- a/documentation/jsdoc/symbols/CAAT.PathSegment.html +++ b/documentation/jsdoc/symbols/CAAT.PathSegment.html @@ -1204,7 +1204,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Point.html b/documentation/jsdoc/symbols/CAAT.Point.html index dbe6c945..9c501192 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 Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Rectangle.html b/documentation/jsdoc/symbols/CAAT.Rectangle.html index 8fa894fa..faa929c0 100644 --- a/documentation/jsdoc/symbols/CAAT.Rectangle.html +++ b/documentation/jsdoc/symbols/CAAT.Rectangle.html @@ -959,7 +959,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Scene.html b/documentation/jsdoc/symbols/CAAT.Scene.html index 2bffaad2..bead118d 100644 --- a/documentation/jsdoc/symbols/CAAT.Scene.html +++ b/documentation/jsdoc/symbols/CAAT.Scene.html @@ -358,6 +358,15 @@

+ +   + +
addActorToInputList(actor, index, position) +
+
Add an actor to a given inputList.
+ + +   @@ -493,6 +502,24 @@

+ +   + +
emptyInputList(index) +
+
Remove all elements from an input list.
+ + + + +   + + +
Enable a number of input lists.
+ + +   @@ -503,6 +530,15 @@

+ +   + + +
Find a pointed actor at position point.
+ + +   @@ -530,6 +566,15 @@

+ +   + +
removeActorFromInputList(actor, index) +
+
remove an actor from a given input list index.
+ + +   @@ -572,7 +617,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -645,6 +690,56 @@

+
+ + +
+ + + addActorToInputList(actor, index, position) + +
+
+ Add an actor to a given inputList. + + +
+ + + + +
+
Parameters:
+ +
+ actor + +
+
an actor instance
+ +
+ index + +
+
the inputList index to add the actor to. This value will be clamped to the number of +available lists.
+ +
+ position + +
+
the position on the selected inputList to add the actor at. This value will be +clamped to the number of available lists.
+ +
+ + + + + + + +
@@ -1443,6 +1538,85 @@

+
+ + +
+ + + emptyInputList(index) + +
+
+ Remove all elements from an input list. + + +
+ + + + +
+
Parameters:
+ +
+ index + +
+
the inputList index to add the actor to. This value will be clamped to the number of +available lists so take care when emptying a non existant inputList index since you could end up emptying +an undesired input list.
+ +
+ + + + + + + + +
+ + +
+ + + enableInputList(size) + +
+
+ Enable a number of input lists. +These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed +actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance. +The system will traverse the whole lists in order trying to find a pointed actor. + +Elements are added to each list either in head or tail. + + +
+ + + + +
+
Parameters:
+ +
+ size + +
+
number of lists.
+ +
+ + + + + + + +
@@ -1487,6 +1661,45 @@

+
+ + +
+ + + findActorAtPosition(point) + +
+
+ Find a pointed actor at position point. +This method tries lo find the correctly pointed actor in two different ways. + + first of all, if inputList is defined, it will look for an actor in it. + + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. + + +
+ + + + +
+
Parameters:
+ +
+ point + +
+
+ +
+ + + + + + + +
@@ -1597,6 +1810,50 @@

+
+ + +
+ + + removeActorFromInputList(actor, index) + +
+
+ remove an actor from a given input list index. +If no index is supplied, the actor will be removed from every input list. + + +
+ + + + +
+
Parameters:
+ +
+ actor + +
+
+ +
+ index + +
+
an optional input list index. This value will be clamped to the number of +available lists.
+ +
+ + + + + + + +
@@ -1748,7 +2005,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ShapeActor.html b/documentation/jsdoc/symbols/CAAT.ShapeActor.html index 4a4d4c0e..510bf3f1 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 Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.SpriteImage.html b/documentation/jsdoc/symbols/CAAT.SpriteImage.html index f6d22692..c32c39a7 100644 --- a/documentation/jsdoc/symbols/CAAT.SpriteImage.html +++ b/documentation/jsdoc/symbols/CAAT.SpriteImage.html @@ -2102,7 +2102,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:07 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.StarActor.html b/documentation/jsdoc/symbols/CAAT.StarActor.html index 0fcb4b93..290a8190 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 Mon Feb 20 2012 23:56:03 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TextActor.html b/documentation/jsdoc/symbols/CAAT.TextActor.html index d094c30f..596fbc9c 100644 --- a/documentation/jsdoc/symbols/CAAT.TextActor.html +++ b/documentation/jsdoc/symbols/CAAT.TextActor.html @@ -1272,7 +1272,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TimerTask.html b/documentation/jsdoc/symbols/CAAT.TimerTask.html index 84f15a34..5d6fd76a 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 Mon Feb 20 2012 23:56:04 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.html b/documentation/jsdoc/symbols/CAAT.html index b49f669f..40601774 100644 --- a/documentation/jsdoc/symbols/CAAT.html +++ b/documentation/jsdoc/symbols/CAAT.html @@ -1955,7 +1955,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html index 63b04610..8b283c31 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html index 0307f14c..ff6966b7 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html index e7060ef1..7eb11a2c 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html index af8cd4f6..6bcf96ec 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.html b/documentation/jsdoc/symbols/CAAT.modules.html index 218f044e..ca895370 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 Mon Feb 20 2012 23:56:02 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:06 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/Function.html b/documentation/jsdoc/symbols/Function.html index 150122aa..b1a92393 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 Mon Feb 20 2012 23:56:04 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:08 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/_global_.html b/documentation/jsdoc/symbols/_global_.html index b450711b..afc1be02 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 Mon Feb 20 2012 23:56:00 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 23 2012 17:39:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_conpoundimage.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_conpoundimage.js.html index 70920f20..8cba59cb 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_conpoundimage.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_conpoundimage.js.html @@ -276,556 +276,559 @@ 269 this.setSpriteIndexAtTime(time); 270 var el= this.mapInfo[this.spriteIndex]; 271 -272 var w= this.getWidth(); -273 var h= this.getHeight(); -274 var xoff= this.offsetX % w; -275 if ( xoff> 0 ) { -276 xoff= xoff-w; -277 } -278 var yoff= this.offsetY % h; -279 if ( yoff> 0 ) { -280 yoff= yoff-h; -281 } -282 -283 var nw= (((this.ownerActor.width-xoff)/w)>>0)+1; -284 var nh= (((this.ownerActor.height-yoff)/h)>>0)+1; -285 var i,j; -286 var ctx= director.ctx; -287 -288 for( i=0; i<nh; i++ ) { -289 for( j=0; j<nw; j++ ) { -290 director.ctx.drawImage( -291 this.image, -292 el.x, el.y, -293 el.width, el.height, -294 (x+xoff+j*el.width)>>0, (y+yoff+i*el.height)>>0, -295 el.width, el.height); -296 } -297 } -298 }, -299 -300 /** -301 * Draws the subimage pointed by imageIndex horizontally inverted. -302 * @param canvas a canvas context. -303 * @param imageIndex {number} a subimage index. -304 * @param x {number} x position in canvas to draw the image. -305 * @param y {number} y position in canvas to draw the image. -306 * -307 * @return this -308 */ -309 paintInvertedH : function(director, time, x, y) { -310 -311 this.setSpriteIndexAtTime(time); -312 -313 var el= this.mapInfo[this.spriteIndex]; -314 -315 var ctx= director.ctx; -316 ctx.save(); -317 //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0); -318 ctx.translate( (x|0) + el.width, y|0 ); -319 ctx.scale(-1, 1); -320 -321 -322 ctx.drawImage( -323 this.image, -324 el.x, el.y, -325 el.width, el.height, -326 this.offsetX>>0, this.offsetY>>0, -327 el.width, el.height ); -328 -329 ctx.restore(); -330 -331 return this; -332 }, -333 /** -334 * Draws the subimage pointed by imageIndex vertically inverted. -335 * @param canvas a canvas context. -336 * @param imageIndex {number} a subimage index. -337 * @param x {number} x position in canvas to draw the image. -338 * @param y {number} y position in canvas to draw the image. -339 * -340 * @return this -341 */ -342 paintInvertedV : function(director, time, x, y) { -343 -344 this.setSpriteIndexAtTime(time); -345 var el= this.mapInfo[this.spriteIndex]; +272 var r= new CAAT.Rectangle(); +273 this.ownerActor.AABB.intersect( director.AABB, r ); +274 +275 var w= this.getWidth(); +276 var h= this.getHeight(); +277 var xoff= (this.offsetX-this.ownerActor.x) % w; +278 if ( xoff> 0 ) { +279 xoff= xoff-w; +280 } +281 var yoff= (this.offsetY-this.ownerActor.y) % h; +282 if ( yoff> 0 ) { +283 yoff= yoff-h; +284 } +285 +286 var nw= (((r.width-xoff)/w)>>0)+1; +287 var nh= (((r.height-yoff)/h)>>0)+1; +288 var i,j; +289 var ctx= director.ctx; +290 +291 for( i=0; i<nh; i++ ) { +292 for( j=0; j<nw; j++ ) { +293 ctx.drawImage( +294 this.image, +295 el.x, el.y, +296 el.width, el.height, +297 (r.x-this.ownerActor.x+xoff+j*el.width)>>0, (r.y-this.ownerActor.y+yoff+i*el.height)>>0, +298 el.width, el.height); +299 } +300 } +301 }, +302 +303 /** +304 * Draws the subimage pointed by imageIndex horizontally inverted. +305 * @param canvas a canvas context. +306 * @param imageIndex {number} a subimage index. +307 * @param x {number} x position in canvas to draw the image. +308 * @param y {number} y position in canvas to draw the image. +309 * +310 * @return this +311 */ +312 paintInvertedH : function(director, time, x, y) { +313 +314 this.setSpriteIndexAtTime(time); +315 +316 var el= this.mapInfo[this.spriteIndex]; +317 +318 var ctx= director.ctx; +319 ctx.save(); +320 //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0); +321 ctx.translate( (x|0) + el.width, y|0 ); +322 ctx.scale(-1, 1); +323 +324 +325 ctx.drawImage( +326 this.image, +327 el.x, el.y, +328 el.width, el.height, +329 this.offsetX>>0, this.offsetY>>0, +330 el.width, el.height ); +331 +332 ctx.restore(); +333 +334 return this; +335 }, +336 /** +337 * Draws the subimage pointed by imageIndex vertically inverted. +338 * @param canvas a canvas context. +339 * @param imageIndex {number} a subimage index. +340 * @param x {number} x position in canvas to draw the image. +341 * @param y {number} y position in canvas to draw the image. +342 * +343 * @return this +344 */ +345 paintInvertedV : function(director, time, x, y) { 346 -347 var ctx= director.ctx; -348 ctx.save(); -349 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); -350 ctx.translate( x|0, (y + el.height) | 0); -351 ctx.scale(1, -1); -352 -353 ctx.drawImage( -354 this.image, -355 el.x, el.y, -356 el.width, el.height, -357 this.offsetX>>0,this.offsetY>>0, -358 el.width, el.height); -359 -360 ctx.restore(); -361 -362 return this; -363 }, -364 /** -365 * Draws the subimage pointed by imageIndex both horizontal and vertically inverted. -366 * @param canvas a canvas context. -367 * @param imageIndex {number} a subimage index. -368 * @param x {number} x position in canvas to draw the image. -369 * @param y {number} y position in canvas to draw the image. -370 * -371 * @return this -372 */ -373 paintInvertedHV : function(director, time, x, y) { -374 -375 this.setSpriteIndexAtTime(time); -376 var el= this.mapInfo[this.spriteIndex]; +347 this.setSpriteIndexAtTime(time); +348 var el= this.mapInfo[this.spriteIndex]; +349 +350 var ctx= director.ctx; +351 ctx.save(); +352 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); +353 ctx.translate( x|0, (y + el.height) | 0); +354 ctx.scale(1, -1); +355 +356 ctx.drawImage( +357 this.image, +358 el.x, el.y, +359 el.width, el.height, +360 this.offsetX>>0,this.offsetY>>0, +361 el.width, el.height); +362 +363 ctx.restore(); +364 +365 return this; +366 }, +367 /** +368 * Draws the subimage pointed by imageIndex both horizontal and vertically inverted. +369 * @param canvas a canvas context. +370 * @param imageIndex {number} a subimage index. +371 * @param x {number} x position in canvas to draw the image. +372 * @param y {number} y position in canvas to draw the image. +373 * +374 * @return this +375 */ +376 paintInvertedHV : function(director, time, x, y) { 377 -378 var ctx= director.ctx; -379 ctx.save(); -380 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); -381 ctx.translate( x | 0, (y + el.height) | 0); -382 ctx.scale(1, -1); -383 ctx.translate(el.width, 0); -384 ctx.scale(-1, 1); -385 -386 ctx.drawImage( -387 this.image, -388 el.x, el.y, -389 el.width, el.height, -390 this.offsetX>>0, this.offsetY>>0, -391 el.width, el.height); -392 -393 ctx.restore(); -394 -395 return this; -396 }, -397 /** -398 * Draws the subimage pointed by imageIndex. -399 * @param canvas a canvas context. -400 * @param imageIndex {number} a subimage index. -401 * @param x {number} x position in canvas to draw the image. -402 * @param y {number} y position in canvas to draw the image. -403 * -404 * @return this -405 */ -406 paintN : function(director, time, x, y) { -407 this.setSpriteIndexAtTime(time); -408 var el= this.mapInfo[this.spriteIndex]; -409 -410 director.ctx.drawImage( -411 this.image, -412 el.x, el.y, -413 el.width, el.height, -414 (this.offsetX+x)>>0, (this.offsetY+y)>>0, -415 el.width, el.height); -416 -417 return this; -418 }, -419 /** -420 * Draws the subimage pointed by imageIndex scaled to the size of w and h. -421 * @param canvas a canvas context. -422 * @param imageIndex {number} a subimage index. -423 * @param x {number} x position in canvas to draw the image. -424 * @param y {number} y position in canvas to draw the image. -425 * @param w {number} new width of the subimage. -426 * @param h {number} new height of the subimage. -427 * -428 * @return this -429 */ -430 paintScaled : function(director, time, x, y) { -431 this.setSpriteIndexAtTime(time); -432 var el= this.mapInfo[this.spriteIndex]; -433 -434 director.ctx.drawImage( -435 this.image, -436 el.x, el.y, -437 el.width, el.height, -438 (this.offsetX+x)>>0, (this.offsetY+y)>>0, -439 this.ownerActor.width, this.ownerActor.height ); -440 -441 return this; -442 }, -443 getCurrentSpriteImageCSSPosition : function() { -444 var el= this.mapInfo[this.spriteIndex]; -445 -446 return '-'+(el.x-this.offsetX)+'px '+ -447 '-'+(el.y-this.offsetY)+'px '+ -448 (this.transformation===this.TR_TILE ? '' : 'no-repeat'); -449 }, -450 /** -451 * Get the number of subimages in this compoundImage -452 * @return {number} -453 */ -454 getNumImages : function() { -455 return this.rows * this.columns; -456 }, -457 /** -458 * TODO: set mapping coordinates for different transformations. -459 * @param imageIndex -460 * @param uvBuffer -461 * @param uvIndex -462 */ -463 setUV : function(uvBuffer, uvIndex) { -464 var im = this.image; -465 -466 if (!im.__texturePage) { -467 return; -468 } -469 -470 var index = uvIndex; -471 var sIndex= this.spriteIndex; -472 var el= this.mapInfo[this.spriteIndex]; -473 -474 var u= el.u; -475 var v= el.v; -476 var u1= el.u1; -477 var v1= el.v1; -478 if ( this.offsetX || this.offsetY ) { -479 var w= this.ownerActor.width; -480 var h= this.ownerActor.height; -481 -482 var tp= im.__texturePage; -483 -484 var _u= -this.offsetX / tp.width; -485 var _v= -this.offsetY / tp.height; -486 var _u1=(w-this.offsetX) / tp.width; -487 var _v1=(h-this.offsetY) / tp.height; -488 -489 u= _u + im.__u; -490 v= _v + im.__v; -491 u1= _u1 + im.__u; -492 v1= _v1 + im.__v; -493 } -494 -495 if (im.inverted) { -496 uvBuffer[index++] = u1; -497 uvBuffer[index++] = v; -498 +378 this.setSpriteIndexAtTime(time); +379 var el= this.mapInfo[this.spriteIndex]; +380 +381 var ctx= director.ctx; +382 ctx.save(); +383 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); +384 ctx.translate( x | 0, (y + el.height) | 0); +385 ctx.scale(1, -1); +386 ctx.translate(el.width, 0); +387 ctx.scale(-1, 1); +388 +389 ctx.drawImage( +390 this.image, +391 el.x, el.y, +392 el.width, el.height, +393 this.offsetX>>0, this.offsetY>>0, +394 el.width, el.height); +395 +396 ctx.restore(); +397 +398 return this; +399 }, +400 /** +401 * Draws the subimage pointed by imageIndex. +402 * @param canvas a canvas context. +403 * @param imageIndex {number} a subimage index. +404 * @param x {number} x position in canvas to draw the image. +405 * @param y {number} y position in canvas to draw the image. +406 * +407 * @return this +408 */ +409 paintN : function(director, time, x, y) { +410 this.setSpriteIndexAtTime(time); +411 var el= this.mapInfo[this.spriteIndex]; +412 +413 director.ctx.drawImage( +414 this.image, +415 el.x, el.y, +416 el.width, el.height, +417 (this.offsetX+x)>>0, (this.offsetY+y)>>0, +418 el.width, el.height); +419 +420 return this; +421 }, +422 /** +423 * Draws the subimage pointed by imageIndex scaled to the size of w and h. +424 * @param canvas a canvas context. +425 * @param imageIndex {number} a subimage index. +426 * @param x {number} x position in canvas to draw the image. +427 * @param y {number} y position in canvas to draw the image. +428 * @param w {number} new width of the subimage. +429 * @param h {number} new height of the subimage. +430 * +431 * @return this +432 */ +433 paintScaled : function(director, time, x, y) { +434 this.setSpriteIndexAtTime(time); +435 var el= this.mapInfo[this.spriteIndex]; +436 +437 director.ctx.drawImage( +438 this.image, +439 el.x, el.y, +440 el.width, el.height, +441 (this.offsetX+x)>>0, (this.offsetY+y)>>0, +442 this.ownerActor.width, this.ownerActor.height ); +443 +444 return this; +445 }, +446 getCurrentSpriteImageCSSPosition : function() { +447 var el= this.mapInfo[this.spriteIndex]; +448 +449 return '-'+(el.x-this.offsetX)+'px '+ +450 '-'+(el.y-this.offsetY)+'px '+ +451 (this.transformation===this.TR_TILE ? '' : 'no-repeat'); +452 }, +453 /** +454 * Get the number of subimages in this compoundImage +455 * @return {number} +456 */ +457 getNumImages : function() { +458 return this.rows * this.columns; +459 }, +460 /** +461 * TODO: set mapping coordinates for different transformations. +462 * @param imageIndex +463 * @param uvBuffer +464 * @param uvIndex +465 */ +466 setUV : function(uvBuffer, uvIndex) { +467 var im = this.image; +468 +469 if (!im.__texturePage) { +470 return; +471 } +472 +473 var index = uvIndex; +474 var sIndex= this.spriteIndex; +475 var el= this.mapInfo[this.spriteIndex]; +476 +477 var u= el.u; +478 var v= el.v; +479 var u1= el.u1; +480 var v1= el.v1; +481 if ( this.offsetX || this.offsetY ) { +482 var w= this.ownerActor.width; +483 var h= this.ownerActor.height; +484 +485 var tp= im.__texturePage; +486 +487 var _u= -this.offsetX / tp.width; +488 var _v= -this.offsetY / tp.height; +489 var _u1=(w-this.offsetX) / tp.width; +490 var _v1=(h-this.offsetY) / tp.height; +491 +492 u= _u + im.__u; +493 v= _v + im.__v; +494 u1= _u1 + im.__u; +495 v1= _v1 + im.__v; +496 } +497 +498 if (im.inverted) { 499 uvBuffer[index++] = u1; -500 uvBuffer[index++] = v1; +500 uvBuffer[index++] = v; 501 -502 uvBuffer[index++] = u; +502 uvBuffer[index++] = u1; 503 uvBuffer[index++] = v1; 504 505 uvBuffer[index++] = u; -506 uvBuffer[index++] = v; -507 } else { +506 uvBuffer[index++] = v1; +507 508 uvBuffer[index++] = u; 509 uvBuffer[index++] = v; -510 -511 uvBuffer[index++] = u1; +510 } else { +511 uvBuffer[index++] = u; 512 uvBuffer[index++] = v; 513 514 uvBuffer[index++] = u1; -515 uvBuffer[index++] = v1; +515 uvBuffer[index++] = v; 516 -517 uvBuffer[index++] = u; +517 uvBuffer[index++] = u1; 518 uvBuffer[index++] = v1; -519 } -520 }, -521 /** -522 * Set the elapsed time needed to change the image index. -523 * @param fps an integer indicating the time in milliseconds to change. -524 * @return this -525 */ -526 setChangeFPS : function(fps) { -527 this.changeFPS= fps; -528 return this; -529 }, -530 /** -531 * Set the transformation to apply to the Sprite image. -532 * Any value of -533 * <li>TR_NONE -534 * <li>TR_FLIP_HORIZONTAL -535 * <li>TR_FLIP_VERTICAL -536 * <li>TR_FLIP_ALL -537 * -538 * @param transformation an integer indicating one of the previous values. -539 * @return this -540 */ -541 setSpriteTransformation : function( transformation ) { -542 this.transformation= transformation; -543 switch(transformation) { -544 case this.TR_FLIP_HORIZONTAL: -545 this.paint= this.paintInvertedH; -546 break; -547 case this.TR_FLIP_VERTICAL: -548 this.paint= this.paintInvertedV; +519 +520 uvBuffer[index++] = u; +521 uvBuffer[index++] = v1; +522 } +523 }, +524 /** +525 * Set the elapsed time needed to change the image index. +526 * @param fps an integer indicating the time in milliseconds to change. +527 * @return this +528 */ +529 setChangeFPS : function(fps) { +530 this.changeFPS= fps; +531 return this; +532 }, +533 /** +534 * Set the transformation to apply to the Sprite image. +535 * Any value of +536 * <li>TR_NONE +537 * <li>TR_FLIP_HORIZONTAL +538 * <li>TR_FLIP_VERTICAL +539 * <li>TR_FLIP_ALL +540 * +541 * @param transformation an integer indicating one of the previous values. +542 * @return this +543 */ +544 setSpriteTransformation : function( transformation ) { +545 this.transformation= transformation; +546 switch(transformation) { +547 case this.TR_FLIP_HORIZONTAL: +548 this.paint= this.paintInvertedH; 549 break; -550 case this.TR_FLIP_ALL: -551 this.paint= this.paintInvertedHV; +550 case this.TR_FLIP_VERTICAL: +551 this.paint= this.paintInvertedV; 552 break; -553 case this.TR_FIXED_TO_SIZE: -554 this.paint= this.paintScaled; -555 break; -556 case this.TR_TILE: -557 this.paint= this.paintTiled; +553 case this.TR_FLIP_ALL: +554 this.paint= this.paintInvertedHV; +555 break; +556 case this.TR_FIXED_TO_SIZE: +557 this.paint= this.paintScaled; 558 break; -559 default: -560 this.paint= this.paintN; -561 } -562 return this; -563 }, -564 -565 /** -566 * Set the sprite animation images index. This method accepts an array of objects which define indexes to -567 * subimages inside this sprite image. -568 * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of -569 * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages -570 * with size rows*columns. -571 * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected -572 * to be an array of strings which are the names of the subobjects contained in the map object. -573 * -574 * @param aAnimationImageIndex an array indicating the Sprite's frames. -575 */ -576 setAnimationImageIndex : function( aAnimationImageIndex ) { -577 this.animationImageIndex= aAnimationImageIndex; -578 this.spriteIndex= aAnimationImageIndex[0]; -579 -580 return this; -581 }, -582 setSpriteIndex : function(index) { -583 this.spriteIndex= index; -584 return this; -585 }, -586 -587 /** -588 * Draws the sprite image calculated and stored in spriteIndex. -589 * -590 * @param director the CAAT.Director object instance that contains the Scene the Actor is in. -591 * @param time an integer indicating the Scene time when the bounding box is to be drawn. -592 */ -593 setSpriteIndexAtTime : function(time) { -594 -595 if ( this.animationImageIndex.length>1 ) { -596 if ( this.prevAnimationTime===-1 ) { -597 this.prevAnimationTime= time; -598 this.spriteIndex=0; -599 } -600 else { -601 var ttime= time; -602 ttime-= this.prevAnimationTime; -603 ttime/= this.changeFPS; -604 ttime%= this.animationImageIndex.length; -605 this.spriteIndex= this.animationImageIndex[Math.floor(ttime)]; -606 } -607 } -608 }, -609 -610 getMapInfo : function( index ) { -611 return this.mapInfo[ index ]; -612 }, -613 -614 /** -615 * This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html -616 * and creates a map into that image. -617 * @param image {Image|HTMLImageElement|Canvas} an image -618 * @param map {object} the map into the image to define subimages. -619 */ -620 initializeFromMap : function( image, map ) { -621 this.initialize( image, 1, 1 ); -622 -623 var key; -624 var helper; -625 var count=0; -626 -627 for( key in map ) { -628 var value= map[key]; +559 case this.TR_TILE: +560 this.paint= this.paintTiled; +561 break; +562 default: +563 this.paint= this.paintN; +564 } +565 return this; +566 }, +567 +568 /** +569 * Set the sprite animation images index. This method accepts an array of objects which define indexes to +570 * subimages inside this sprite image. +571 * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of +572 * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages +573 * with size rows*columns. +574 * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected +575 * to be an array of strings which are the names of the subobjects contained in the map object. +576 * +577 * @param aAnimationImageIndex an array indicating the Sprite's frames. +578 */ +579 setAnimationImageIndex : function( aAnimationImageIndex ) { +580 this.animationImageIndex= aAnimationImageIndex; +581 this.spriteIndex= aAnimationImageIndex[0]; +582 +583 return this; +584 }, +585 setSpriteIndex : function(index) { +586 this.spriteIndex= index; +587 return this; +588 }, +589 +590 /** +591 * Draws the sprite image calculated and stored in spriteIndex. +592 * +593 * @param director the CAAT.Director object instance that contains the Scene the Actor is in. +594 * @param time an integer indicating the Scene time when the bounding box is to be drawn. +595 */ +596 setSpriteIndexAtTime : function(time) { +597 +598 if ( this.animationImageIndex.length>1 ) { +599 if ( this.prevAnimationTime===-1 ) { +600 this.prevAnimationTime= time; +601 this.spriteIndex=0; +602 } +603 else { +604 var ttime= time; +605 ttime-= this.prevAnimationTime; +606 ttime/= this.changeFPS; +607 ttime%= this.animationImageIndex.length; +608 this.spriteIndex= this.animationImageIndex[Math.floor(ttime)]; +609 } +610 } +611 }, +612 +613 getMapInfo : function( index ) { +614 return this.mapInfo[ index ]; +615 }, +616 +617 /** +618 * This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html +619 * and creates a map into that image. +620 * @param image {Image|HTMLImageElement|Canvas} an image +621 * @param map {object} the map into the image to define subimages. +622 */ +623 initializeFromMap : function( image, map ) { +624 this.initialize( image, 1, 1 ); +625 +626 var key; +627 var helper; +628 var count=0; 629 -630 helper= new CAAT.SpriteImageHelper( -631 value.x, -632 value.y, -633 value.width, -634 value.height, -635 image.width, -636 image.height -637 ); -638 -639 this.mapInfo[key]= helper; -640 -641 // set a default spriteIndex -642 if ( !count ) { -643 this.setAnimationImageIndex( [key] ); -644 } -645 -646 count++; -647 } +630 for( key in map ) { +631 var value= map[key]; +632 +633 helper= new CAAT.SpriteImageHelper( +634 value.x, +635 value.y, +636 value.width, +637 value.height, +638 image.width, +639 image.height +640 ); +641 +642 this.mapInfo[key]= helper; +643 +644 // set a default spriteIndex +645 if ( !count ) { +646 this.setAnimationImageIndex( [key] ); +647 } 648 -649 return this; -650 }, +649 count++; +650 } 651 -652 /** -653 * -654 * @param image {Image|HTMLImageElement|Canvas} -655 * @param map object with pairs "<a char>" : { -656 * id : {number}, -657 * height : {number}, -658 * xoffset : {number}, -659 * letter : {string}, -660 * yoffset : {number}, -661 * width : {number}, -662 * xadvance: {number}, -663 * y : {number}, -664 * x : {number} -665 * } -666 */ -667 initializeAsGlyphDesigner : function( image, map ) { -668 this.initialize( image, 1, 1 ); -669 -670 var key; -671 var helper; -672 var count=0; -673 -674 for( key in map ) { -675 var value= map[key]; +652 return this; +653 }, +654 +655 /** +656 * +657 * @param image {Image|HTMLImageElement|Canvas} +658 * @param map object with pairs "<a char>" : { +659 * id : {number}, +660 * height : {number}, +661 * xoffset : {number}, +662 * letter : {string}, +663 * yoffset : {number}, +664 * width : {number}, +665 * xadvance: {number}, +666 * y : {number}, +667 * x : {number} +668 * } +669 */ +670 initializeAsGlyphDesigner : function( image, map ) { +671 this.initialize( image, 1, 1 ); +672 +673 var key; +674 var helper; +675 var count=0; 676 -677 helper= new CAAT.SpriteImageHelper( -678 value.x, -679 value.y, -680 value.width, -681 value.height, -682 image.width, -683 image.height -684 ); -685 -686 helper.xoffset= typeof value.xoffset==='undefined' ? 0 : value.xoffset; -687 helper.yoffset= typeof value.yoffset==='undefined' ? 0 : value.yoffset; -688 helper.xadvance= typeof value.xadvance==='undefined' ? value.width : value.xadvance; -689 -690 this.mapInfo[key]= helper; -691 -692 // set a default spriteIndex -693 if ( !count ) { -694 this.setAnimationImageIndex( [key] ); -695 } -696 -697 count++; -698 } +677 for( key in map ) { +678 var value= map[key]; +679 +680 helper= new CAAT.SpriteImageHelper( +681 value.x, +682 value.y, +683 value.width, +684 value.height, +685 image.width, +686 image.height +687 ); +688 +689 helper.xoffset= typeof value.xoffset==='undefined' ? 0 : value.xoffset; +690 helper.yoffset= typeof value.yoffset==='undefined' ? 0 : value.yoffset; +691 helper.xadvance= typeof value.xadvance==='undefined' ? value.width : value.xadvance; +692 +693 this.mapInfo[key]= helper; +694 +695 // set a default spriteIndex +696 if ( !count ) { +697 this.setAnimationImageIndex( [key] ); +698 } 699 -700 return this; -701 -702 }, -703 -704 /** -705 * -706 * @param image -707 * @param map: Array<{c: "a", width: 40}> -708 */ -709 initializeAsFontMap : function( image, chars ) { -710 this.initialize( image, 1, 1 ); -711 -712 var helper; -713 var x=0; +700 count++; +701 } +702 +703 return this; +704 +705 }, +706 +707 /** +708 * +709 * @param image +710 * @param map: Array<{c: "a", width: 40}> +711 */ +712 initializeAsFontMap : function( image, chars ) { +713 this.initialize( image, 1, 1 ); 714 -715 for( var i=0;i<chars.length;i++ ) { -716 var value= chars[i]; +715 var helper; +716 var x=0; 717 -718 helper= new CAAT.SpriteImageHelper( -719 x, -720 0, -721 value.width, -722 image.height, -723 image.width, -724 image.height -725 ); -726 -727 helper.xoffset= 0; -728 helper.yoffset= 0; -729 helper.xadvance= value.width; -730 -731 -732 x += value.width; +718 for( var i=0;i<chars.length;i++ ) { +719 var value= chars[i]; +720 +721 helper= new CAAT.SpriteImageHelper( +722 x, +723 0, +724 value.width, +725 image.height, +726 image.width, +727 image.height +728 ); +729 +730 helper.xoffset= 0; +731 helper.yoffset= 0; +732 helper.xadvance= value.width; 733 -734 this.mapInfo[chars[i].c]= helper; -735 -736 // set a default spriteIndex -737 if ( !i ) { -738 this.setAnimationImageIndex( [chars[i].c] ); -739 } -740 } -741 -742 return this; -743 }, +734 +735 x += value.width; +736 +737 this.mapInfo[chars[i].c]= helper; +738 +739 // set a default spriteIndex +740 if ( !i ) { +741 this.setAnimationImageIndex( [chars[i].c] ); +742 } +743 } 744 -745 /** -746 * This method creates a font sprite image based on a proportional font -747 * It assumes the font is evenly spaced in the image -748 * Example: -749 * var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( -750 * director.getImage('numbers'), -751 * "0123456789" -752 * ); -753 */ -754 -755 initializeAsMonoTypeFontMap : function( image, chars ) { -756 var map = []; -757 var charArr = chars.split(""); -758 -759 var w = image.width / charArr.length >> 0; -760 -761 for( var i=0;i<charArr.length;i++ ) { -762 map.push({c: charArr[i], width: w }); -763 } -764 -765 return this.initializeAsFontMap(image,map); -766 }, +745 return this; +746 }, +747 +748 /** +749 * This method creates a font sprite image based on a proportional font +750 * It assumes the font is evenly spaced in the image +751 * Example: +752 * var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( +753 * director.getImage('numbers'), +754 * "0123456789" +755 * ); +756 */ +757 +758 initializeAsMonoTypeFontMap : function( image, chars ) { +759 var map = []; +760 var charArr = chars.split(""); +761 +762 var w = image.width / charArr.length >> 0; +763 +764 for( var i=0;i<charArr.length;i++ ) { +765 map.push({c: charArr[i], width: w }); +766 } 767 -768 stringWidth : function( str ) { -769 var i,l,w=0,charInfo; +768 return this.initializeAsFontMap(image,map); +769 }, 770 -771 for( i=0, l=str.length; i<l; i++ ) { -772 charInfo= this.mapInfo[ str.charAt(i) ]; -773 if ( charInfo ) { -774 w+= charInfo.xadvance; -775 } -776 } -777 -778 return w; -779 }, +771 stringWidth : function( str ) { +772 var i,l,w=0,charInfo; +773 +774 for( i=0, l=str.length; i<l; i++ ) { +775 charInfo= this.mapInfo[ str.charAt(i) ]; +776 if ( charInfo ) { +777 w+= charInfo.xadvance; +778 } +779 } 780 -781 stringHeight : function() { -782 if ( this.fontHeight ) { -783 return this.fontHeight; -784 } -785 -786 var y= 0; -787 for( var i in this.mapInfo ) { -788 var mi= this.mapInfo[i]; -789 -790 var h= mi.height+mi.yoffset; -791 if ( h>y ) { -792 y=h; -793 } -794 } -795 -796 this.fontHeight= y; -797 return this.fontHeight; -798 }, -799 -800 drawString : function( ctx, str, x, y ) { -801 var i, l, charInfo, w; -802 var charArr = str.split(""); -803 -804 for( i=0; i<charArr.length; i++ ) { -805 charInfo= this.mapInfo[ charArr[i] ]; -806 if ( charInfo ) { -807 w= charInfo.width; -808 ctx.drawImage( -809 this.image, -810 charInfo.x, charInfo.y, -811 w, charInfo.height, -812 -813 x + charInfo.xoffset, y + charInfo.yoffset, -814 w, charInfo.height ); +781 return w; +782 }, +783 +784 stringHeight : function() { +785 if ( this.fontHeight ) { +786 return this.fontHeight; +787 } +788 +789 var y= 0; +790 for( var i in this.mapInfo ) { +791 var mi= this.mapInfo[i]; +792 +793 var h= mi.height+mi.yoffset; +794 if ( h>y ) { +795 y=h; +796 } +797 } +798 +799 this.fontHeight= y; +800 return this.fontHeight; +801 }, +802 +803 drawString : function( ctx, str, x, y ) { +804 var i, l, charInfo, w; +805 var charArr = str.split(""); +806 +807 for( i=0; i<charArr.length; i++ ) { +808 charInfo= this.mapInfo[ charArr[i] ]; +809 if ( charInfo ) { +810 w= charInfo.width; +811 ctx.drawImage( +812 this.image, +813 charInfo.x, charInfo.y, +814 w, charInfo.height, 815 -816 x+= charInfo.xadvance; -817 } -818 } -819 } -820 -821 -822 }; -823 })(); -824 \ No newline at end of file +816 x + charInfo.xoffset, y + charInfo.yoffset, +817 w, charInfo.height ); +818 +819 x+= charInfo.xadvance; +820 } +821 } +822 } +823 +824 +825 }; +826 })(); +827 \ No newline at end of file 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 f5b9b620..4839c6df 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 @@ -703,1383 +703,1388 @@ 696 */ 697 animate : function(director, time) { 698 this.setModelViewMatrix(this); -699 this.setScreenBounds(); -700 -701 this.dirty= false; -702 this.invalid= false; -703 this.dirtyRectsIndex= -1; -704 this.cDirtyRects= []; -705 -706 var cl= this.childrenList; -707 var cli; -708 for (var i = 0; i < cl.length; i++) { -709 cli= cl[i]; -710 var tt = cli.time - cli.start_time; -711 cli.animate(this, tt); -712 } -713 -714 return this; -715 }, -716 /** -717 * Add a rectangle to the list of dirty screen areas which should be redrawn. -718 * This is the opposite method to clear the whole screen and repaint everything again. -719 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this -720 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or -721 * even lowers performance under others, so it is a developer choice to activate them via a call to -722 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). -723 * -724 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping -725 * rectangles will be removed and intersecting ones will be unioned. -726 * -727 * Before calling this method, check if this.dirtyRectsEnabled is true. -728 * -729 * @param rectangle {CAAT.Rectangle} -730 */ -731 addDirtyRect : function( rectangle ) { -732 -733 if ( rectangle.isEmpty() ) { -734 return; -735 } -736 -737 var i, dr, j, drj; -738 var cdr= this.cDirtyRects; -739 -740 for( i=0; i<cdr.length; i++ ) { -741 dr= cdr[i]; -742 if ( !dr.isEmpty() && dr.intersects( rectangle ) ) { -743 var intersected= true; -744 while( intersected ) { -745 dr.unionRectangle( rectangle ); -746 -747 for( j=0; j<cdr.length; j++ ) { -748 if ( j!==i ) { -749 drj= cdr[j]; -750 if ( !drj.isEmpty() && drj.intersects( dr ) ) { -751 dr.unionRectangle( drj ); -752 drj.setEmpty(); -753 break; -754 } -755 } -756 } -757 -758 if ( j==cdr.length ) { -759 intersected= false; -760 } -761 } -762 -763 for( j=0; j<cdr.length; j++ ) { -764 if ( cdr[j].isEmpty() ) { -765 cdr.splice( j, 1 ); -766 } -767 } -768 -769 return; -770 } -771 } -772 -773 this.dirtyRectsIndex++; -774 -775 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { -776 for( i=0; i<32; i++ ) { -777 this.dirtyRects.push( new CAAT.Rectangle() ); -778 } -779 } -780 -781 var r= this.dirtyRects[ this.dirtyRectsIndex ]; -782 -783 r.x= rectangle.x; -784 r.y= rectangle.y; -785 r.x1= rectangle.x1; -786 r.y1= rectangle.y1; -787 r.width= rectangle.width; -788 r.height= rectangle.height; -789 -790 this.cDirtyRects.push( r ); -791 -792 }, -793 /** -794 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of -795 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from -796 * one to another, first of all an scene is drawn to offscreen, and that image is translated. -797 * <p> -798 * Until the creation of this method, both scenes where drawn while transitioning with -799 * its performance penalty since drawing two scenes could be twice as expensive than drawing -800 * only one. -801 * <p> -802 * Though a high performance increase, we should keep an eye on memory consumption. -803 * -804 * @param ctx a <code>canvas.getContext('2d')</code> instnce. -805 * @param scene {CAAT.Scene} the scene to draw offscreen. -806 */ -807 renderToContext : function(ctx, scene) { -808 /** -809 * draw actors on scene. -810 */ -811 if (scene.isInAnimationFrame(this.time)) { -812 ctx.globalAlpha = 1; -813 ctx.globalCompositeOperation = 'source-over'; -814 ctx.clearRect(0, 0, this.width, this.height); -815 ctx.setTransform(1,0,0, 0,1,0); -816 -817 var octx = this.ctx; -818 var ocrc = this.crc; -819 -820 this.ctx = this.crc = ctx; -821 ctx.save(); -822 -823 /** -824 * to draw an scene to an offscreen canvas, we have to: -825 * 1.- save diector's world model view matrix -826 * 2.- set no transformation on director since we want the offscreen to -827 * be drawn 1:1. -828 * 3.- set world dirty flag, so that the scene will recalculate its matrices -829 * 4.- animate the scene -830 * 5.- paint the scene -831 * 6.- restore world model view matrix. -832 */ -833 var matwmv= this.worldModelViewMatrix; -834 this.worldModelViewMatrix= new CAAT.Matrix(); -835 this.wdirty= true; -836 scene.animate(this, scene.time); -837 if ( scene.onRenderStart ) { -838 scene.onRenderStart(scene.time); -839 } -840 scene.paintActor(this, scene.time); -841 if ( scene.onRenderEnd ) { -842 scene.onRenderEnd(scene.time); -843 } -844 this.worldModelViewMatrix = matwmv; -845 -846 ctx.restore(); -847 -848 this.ctx = octx; -849 this.crc = ocrc; -850 } -851 }, -852 /** -853 * Add a new Scene to Director's Scene list. By adding a Scene to the Director -854 * does not mean it will be immediately visible, you should explicitly call either -855 * <ul> -856 * <li>easeIn -857 * <li>easeInOut -858 * <li>easeInOutRandom -859 * <li>setScene -860 * <li>or any of the scene switching methods -861 * </ul> -862 * -863 * @param scene {CAAT.Scene} an CAAT.Scene object. -864 */ -865 addScene : function(scene) { -866 scene.setBounds(0, 0, this.width, this.height); -867 this.scenes.push(scene); -868 scene.setEaseListener(this); -869 if (null === this.currentScene) { -870 this.setScene(0); -871 } -872 }, -873 /** -874 * Get the number of scenes contained in the Director. -875 * @return {number} the number of scenes contained in the Director. -876 */ -877 getNumScenes : function() { -878 return this.scenes.length; -879 }, -880 /** -881 * This method offers full control over the process of switching between any given two Scenes. -882 * To apply this method, you must specify the type of transition to apply for each Scene and -883 * the anchor to keep the Scene pinned at. -884 * <p> -885 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: -886 * <ul> -887 * <li>EASE_ROTATION -888 * <li>EASE_SCALE -889 * <li>EASE_TRANSLATION -890 * </ul> -891 * -892 * <p> -893 * The anchor will be any of these values defined in CAAT.Actor.prototype: -894 * <ul> -895 * <li>ANCHOR_CENTER -896 * <li>ANCHOR_TOP -897 * <li>ANCHOR_BOTTOM -898 * <li>ANCHOR_LEFT -899 * <li>ANCHOR_RIGHT -900 * <li>ANCHOR_TOP_LEFT -901 * <li>ANCHOR_TOP_RIGHT -902 * <li>ANCHOR_BOTTOM_LEFT -903 * <li>ANCHOR_BOTTOM_RIGHT -904 * </ul> -905 * -906 * <p> -907 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the -908 * point by which the scene will scaled. -909 * -910 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. -911 * @param typein integer indicating the type of transition to apply to the bringing in Scene. -912 * @param anchorin integer indicating the anchor of the bringing in Scene. -913 * @param outSceneIndex integer indicating the Scene index to take away from the Director. -914 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. -915 * @param anchorout integer indicating the anchor of the taking away Scene. -916 * @param time inteter indicating the time to perform the process of switchihg between Scene object -917 * in milliseconds. -918 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to -919 * the scenes. -920 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. -921 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. -922 */ -923 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { -924 -925 if (inSceneIndex === this.getCurrentSceneIndex()) { -926 return; -927 } -928 -929 var ssin = this.scenes[ inSceneIndex ]; -930 var sout = this.scenes[ outSceneIndex ]; -931 -932 if (!this.glEnabled && !navigator.browser==='iOS') { -933 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); -934 this.renderToContext(this.transitionScene.ctx, sout); -935 sout = this.transitionScene; -936 } -937 -938 ssin.setExpired(false); -939 sout.setExpired(false); -940 -941 ssin.mouseEnabled = false; -942 sout.mouseEnabled = false; -943 -944 ssin.resetTransform(); -945 sout.resetTransform(); -946 -947 ssin.setLocation(0, 0); -948 sout.setLocation(0, 0); -949 -950 ssin.alpha = 1; -951 sout.alpha = 1; -952 -953 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { -954 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); -955 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { -956 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); -957 } else { -958 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); -959 } -960 -961 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { -962 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); -963 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { -964 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); -965 } else { -966 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); -967 } -968 -969 this.childrenList = []; -970 -971 this.addChild(sout); -972 this.addChild(ssin); -973 }, -974 /** -975 * This method will switch between two given Scene indexes (ie, take away scene number 2, -976 * and bring in scene number 5). -977 * <p> -978 * It will randomly choose for each Scene the type of transition to apply and the anchor -979 * point of each transition type. -980 * <p> -981 * It will also set for different kind of transitions the following interpolators: -982 * <ul> -983 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. -984 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 -985 * <li>EASE_TRANSLATION -> BounceOutInterpolator -986 * </ul> -987 * -988 * <p> -989 * These are the default values, and could not be changed by now. -990 * This method in final instance delegates the process to easeInOutMethod. -991 * -992 * @see easeInOutMethod. -993 * -994 * @param inIndex integer indicating the entering scene index. -995 * @param outIndex integer indicating the exiting scene index. -996 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. -997 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. -998 */ -999 easeInOutRandom : function(inIndex, outIndex, time, alpha) { -1000 -1001 var pin = Math.random(); -1002 var pout = Math.random(); -1003 -1004 var typeIn; -1005 var interpolatorIn; -1006 -1007 if (pin < 0.33) { -1008 typeIn = CAAT.Scene.prototype.EASE_ROTATION; -1009 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -1010 } else if (pin < 0.66) { -1011 typeIn = CAAT.Scene.prototype.EASE_SCALE; -1012 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); -1013 } else { -1014 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; -1015 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); -1016 } -1017 -1018 var typeOut; -1019 var interpolatorOut; -1020 -1021 if (pout < 0.33) { -1022 typeOut = CAAT.Scene.prototype.EASE_ROTATION; -1023 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -1024 } else if (pout < 0.66) { -1025 typeOut = CAAT.Scene.prototype.EASE_SCALE; -1026 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); -1027 } else { -1028 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; -1029 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); -1030 } -1031 -1032 this.easeInOut( -1033 inIndex, -1034 typeIn, -1035 (Math.random() * 8.99) >> 0, -1036 -1037 outIndex, -1038 typeOut, -1039 (Math.random() * 8.99) >> 0, -1040 -1041 time, -1042 alpha, -1043 -1044 interpolatorIn, -1045 interpolatorOut); -1046 -1047 }, -1048 /** -1049 * This method changes Director's current Scene to the scene index indicated by -1050 * inSceneIndex parameter. The Scene running in the director won't be eased out. -1051 * -1052 * @see {CAAT.Interpolator} -1053 * @see {CAAT.Actor} -1054 * @see {CAAT.Scene} -1055 * -1056 * @param inSceneIndex integer indicating the new Scene to set as current. -1057 * @param type integer indicating the type of transition to apply to bring the new current -1058 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, -1059 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. -1060 * @param time integer indicating how much time in milliseconds the Scene entrance will take. -1061 * @param alpha boolean indicating whether alpha transparency fading will be applied to the -1062 * entereing Scene. -1063 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of -1064 * CAAT.Actor.prototype.ANCHOR_* values. -1065 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to -1066 * apply. -1067 */ -1068 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { -1069 var sin = this.scenes[ inSceneIndex ]; -1070 if (type === CAAT.Scene.prototype.EASE_ROTATION) { -1071 sin.easeRotationIn(time, alpha, anchor, interpolator); -1072 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { -1073 sin.easeScaleIn(0, time, alpha, anchor, interpolator); -1074 } else { -1075 sin.easeTranslationIn(time, alpha, anchor, interpolator); -1076 } -1077 this.childrenList = []; -1078 this.addChild(sin); -1079 -1080 sin.resetTransform(); -1081 sin.setLocation(0, 0); -1082 sin.alpha = 1; -1083 sin.mouseEnabled = false; -1084 sin.setExpired(false); -1085 }, -1086 /** -1087 * Changes (or sets) the current Director scene to the index -1088 * parameter. There will be no transition on scene change. -1089 * @param sceneIndex {number} an integer indicating the index of the target Scene -1090 * to be shown. -1091 */ -1092 setScene : function(sceneIndex) { -1093 var sin = this.scenes[ sceneIndex ]; -1094 this.childrenList = []; -1095 this.addChild(sin); -1096 this.currentScene = sin; -1097 -1098 sin.setExpired(false); -1099 sin.mouseEnabled = true; -1100 sin.resetTransform(); -1101 sin.setLocation(0, 0); -1102 sin.alpha = 1; -1103 -1104 sin.activated(); -1105 }, -1106 /** -1107 * This method will change the current Scene by the Scene indicated as parameter. -1108 * It will apply random values for anchor and transition type. -1109 * @see easeInOutRandom -1110 * -1111 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. -1112 * @param time {number} an integer indicating the time the Scene transition will take. -1113 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1114 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1115 */ -1116 switchToScene : function(iNewSceneIndex, time, alpha, transition) { -1117 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1118 -1119 if (!transition) { -1120 this.setScene(iNewSceneIndex); -1121 } -1122 else { -1123 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); -1124 } -1125 }, -1126 /** -1127 * Sets the previous Scene in sequence as the current Scene. -1128 * @see switchToScene. -1129 * -1130 * @param time {number} integer indicating the time the Scene transition will take. -1131 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1132 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1133 */ -1134 switchToPrevScene : function(time, alpha, transition) { -1135 -1136 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1137 -1138 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { -1139 return; -1140 } -1141 -1142 if (!transition) { -1143 this.setScene(currentSceneIndex - 1); -1144 } -1145 else { -1146 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); -1147 } -1148 }, -1149 /** -1150 * Sets the previous Scene in sequence as the current Scene. -1151 * @see switchToScene. -1152 * -1153 * @param time {number} integer indicating the time the Scene transition will take. -1154 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1155 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1156 */ -1157 switchToNextScene: function(time, alpha, transition) { -1158 -1159 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1160 -1161 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { -1162 return; -1163 } -1164 -1165 if (!transition) { -1166 this.setScene(currentSceneIndex + 1); -1167 } -1168 else { -1169 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); -1170 } -1171 }, -1172 mouseEnter : function(mouseEvent) { -1173 }, -1174 mouseExit : function(mouseEvent) { -1175 }, -1176 mouseMove : function(mouseEvent) { -1177 }, -1178 mouseDown : function(mouseEvent) { -1179 }, -1180 mouseUp : function(mouseEvent) { -1181 }, -1182 mouseDrag : function(mouseEvent) { -1183 }, -1184 /** -1185 * Scene easing listener. Notifies scenes when they're about to be activated (set as current -1186 * director's scene). -1187 * -1188 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. -1189 * @param b_easeIn {boolean} scene enters or exits ? -1190 */ -1191 easeEnd : function(scene, b_easeIn) { -1192 // scene is going out -1193 if (!b_easeIn) { -1194 -1195 scene.setExpired(true); -1196 } else { -1197 this.currentScene = scene; -1198 this.currentScene.activated(); -1199 } -1200 -1201 scene.mouseEnabled = true; -1202 scene.emptyBehaviorList(); -1203 }, -1204 /** -1205 * Return the index for a given Scene object contained in the Director. -1206 * @param scene {CAAT.Scene} -1207 */ -1208 getSceneIndex : function(scene) { -1209 for (var i = 0; i < this.scenes.length; i++) { -1210 if (this.scenes[i] === scene) { -1211 return i; -1212 } -1213 } -1214 return -1; -1215 }, -1216 /** -1217 * Get a concrete director's scene. -1218 * @param index {number} an integer indicating the scene index. -1219 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. -1220 */ -1221 getScene : function(index) { -1222 return this.scenes[index]; -1223 }, -1224 /** -1225 * Return the index of the current scene in the Director's scene list. -1226 * @return {number} the current scene's index. -1227 */ -1228 getCurrentSceneIndex : function() { -1229 return this.getSceneIndex(this.currentScene); -1230 }, -1231 /** -1232 * Return the running browser name. -1233 * @return {string} the browser name. -1234 */ -1235 getBrowserName : function() { -1236 return this.browserInfo.browser; -1237 }, -1238 /** -1239 * Return the running browser version. -1240 * @return {string} the browser version. -1241 */ -1242 getBrowserVersion : function() { -1243 return this.browserInfo.version; -1244 }, -1245 /** -1246 * Return the operating system name. -1247 * @return {string} the os name. -1248 */ -1249 getOSName : function() { -1250 return this.browserInfo.OS; -1251 }, -1252 /** -1253 * Gets the resource with the specified resource name. -1254 * The Director holds a collection called <code>imagesCache</code> -1255 * where you can store a JSON of the form -1256 * <code>[ { id: imageId, image: imageObject } ]</code>. -1257 * This structure will be used as a resources cache. -1258 * There's a CAAT.ImagePreloader class to preload resources and -1259 * generate this structure on loading finalization. -1260 * -1261 * @param sId {object} an String identifying a resource. -1262 */ -1263 getImage : function(sId) { -1264 var ret = this.imagesCache[sId]; -1265 if (ret) { -1266 return ret; -1267 } -1268 -1269 for (var i = 0; i < this.imagesCache.length; i++) { -1270 if (this.imagesCache[i].id === sId) { -1271 return this.imagesCache[i].image; -1272 } -1273 } -1274 -1275 return null; -1276 }, -1277 /** -1278 * Adds an audio to the cache. -1279 * -1280 * @see CAAT.AudioManager.addAudio -1281 * @return this -1282 */ -1283 addAudio : function(id, url) { -1284 this.audioManager.addAudio(id, url); -1285 return this; -1286 }, -1287 /** -1288 * Plays the audio instance identified by the id. -1289 * @param id {object} the object used to store a sound in the audioCache. -1290 */ -1291 audioPlay : function(id) { -1292 this.audioManager.play(id); -1293 }, -1294 /** -1295 * Loops an audio instance identified by the id. -1296 * @param id {object} the object used to store a sound in the audioCache. -1297 * -1298 * @return {HTMLElement|null} the value from audioManager.loop -1299 */ -1300 audioLoop : function(id) { -1301 return this.audioManager.loop(id); -1302 }, -1303 endSound : function() { -1304 return this.audioManager.endSound(); -1305 }, -1306 setSoundEffectsEnabled : function(enabled) { -1307 return this.audioManager.setSoundEffectsEnabled(enabled); -1308 }, -1309 setMusicEnabled : function(enabled) { -1310 return this.audioManager.setMusicEnabled(enabled); -1311 }, -1312 isMusicEnabled : function() { -1313 return this.audioManager.isMusicEnabled(); -1314 }, -1315 isSoundEffectsEnabled : function() { -1316 return this.audioManager.isSoundEffectsEnabled(); -1317 }, -1318 setVolume : function( id, volume ) { -1319 return this.audioManager.setVolume( id, volume ); -1320 }, -1321 /** -1322 * Removes Director's scenes. -1323 */ -1324 emptyScenes : function() { -1325 this.scenes = []; -1326 }, -1327 /** -1328 * Adds an scene to this Director. -1329 * @param scene {CAAT.Scene} a scene object. -1330 */ -1331 addChild : function(scene) { -1332 scene.parent = this; -1333 this.childrenList.push(scene); -1334 }, -1335 /** -1336 * @Deprecated use CAAT.loop instead. -1337 * @param fps -1338 * @param callback -1339 * @param callback2 -1340 */ -1341 loop : function(fps,callback,callback2) { -1342 if ( callback2 ) { -1343 this.onRenderStart= callback; -1344 this.onRenderEnd= callback2; -1345 } else if (callback) { -1346 this.onRenderEnd= callback; -1347 } -1348 CAAT.loop(); -1349 }, -1350 /** -1351 * Starts the director animation.If no scene is explicitly selected, the current Scene will -1352 * be the first scene added to the Director. -1353 * <p> -1354 * The fps parameter will set the animation quality. Higher values, -1355 * means CAAT will try to render more frames in the same second (at the -1356 * expense of cpu power at least until hardware accelerated canvas rendering -1357 * context are available). A value of 60 is a high frame rate and should not be exceeded. -1358 * -1359 * @param fps {number} integer value indicating the target frames per second to run -1360 * the animation at. -1361 */ -1362 renderFrame : function(fps, callback) { -1363 var t = new Date().getTime(), -1364 delta = t - this.timeline; -1365 -1366 /* -1367 check for massive frame time. if for example the current browser tab is minified or taken out of -1368 foreground, the system will account for a bit time interval. minify that impact by lowering down -1369 the elapsed time (virtual timelines FTW) -1370 */ -1371 if ( delta > 500 ) { -1372 delta= 500; -1373 } -1374 -1375 if ( this.onRenderStart ) { -1376 this.onRenderStart(delta); -1377 } -1378 -1379 this.render(delta); -1380 -1381 if ( this.debugInfo ) { -1382 this.debugInfo(this.statistics); -1383 } -1384 -1385 this.timeline = t; -1386 -1387 if (this.onRenderEnd) { -1388 this.onRenderEnd(delta); -1389 } -1390 }, -1391 endLoop : function () { -1392 }, -1393 /** -1394 * This method states whether the director must clear background before rendering -1395 * each frame. -1396 * -1397 * The clearing method could be: -1398 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. -1399 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled -1400 * will have their areas redrawn. -1401 * + CAAT.Director.CLEAR_NONE. clears nothing. -1402 * -1403 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} -1404 * @return this. -1405 */ -1406 setClear : function(clear) { -1407 this.clear = clear; -1408 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { -1409 this.dirtyRectsEnabled= true; -1410 } -1411 return this; -1412 }, -1413 /** -1414 * Get this Director's AudioManager instance. -1415 * @return {CAAT.AudioManager} the AudioManager instance. -1416 */ -1417 getAudioManager : function() { -1418 return this.audioManager; -1419 }, -1420 /** -1421 * Acculumate dom elements position to properly offset on-screen mouse/touch events. -1422 * @param node -1423 */ -1424 cumulateOffset : function(node, parent, prop) { -1425 var left= prop+'Left'; -1426 var top= prop+'Top'; -1427 var x=0, y=0, style; -1428 -1429 while( navigator.browser!=='iOS' && node && node.style ) { -1430 if ( node.currentStyle ) { -1431 style= node.currentStyle['position']; -1432 } else { -1433 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); -1434 style= style ? style.getPropertyValue('position') : null; -1435 } -1436 -1437 // if (!/^(relative|absolute|fixed)$/.test(style)) { -1438 if (!/^(fixed)$/.test(style)) { -1439 x += node[left]; -1440 y+= node[top]; -1441 node = node[parent]; -1442 } else { -1443 break; -1444 } -1445 } -1446 -1447 return { -1448 x: x, -1449 y: y, -1450 style: style -1451 }; -1452 }, -1453 getOffset : function( node ) { -1454 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); -1455 if ( res.style==='fixed' ) { -1456 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); -1457 return { -1458 x: res.x + res2.x, -1459 y: res.y + res2.y -1460 }; -1461 } -1462 -1463 return { -1464 x: res.x, -1465 y: res.y -1466 }; -1467 }, -1468 /** -1469 * Normalize input event coordinates to be related to (0,0) canvas position. -1470 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. -1471 * @param e {MouseEvent} a mouse event from an input event. -1472 */ -1473 getCanvasCoord : function(point, e) { -1474 -1475 var posx = 0; -1476 var posy = 0; -1477 if (!e) e = window.event; -1478 -1479 if (e.pageX || e.pageY) { -1480 posx = e.pageX; -1481 posy = e.pageY; -1482 } -1483 else if (e.clientX || e.clientY) { -1484 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; -1485 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; -1486 } -1487 -1488 var offset= this.getOffset(e.target); -1489 -1490 posx-= offset.x; -1491 posy-= offset.y; -1492 -1493 ////////////// -1494 // transformar coordenada inversamente con affine transform de director. -1495 -1496 var pt= new CAAT.Point( posx, posy ); -1497 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); -1498 this.modelViewMatrixI.transformCoord(pt); -1499 posx= pt.x; -1500 posy= pt.y -1501 -1502 point.set(posx, posy); -1503 this.screenMousePoint.set(posx, posy); +699 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); +700 this.setScreenBounds(); +701 +702 this.dirty= false; +703 this.invalid= false; +704 this.dirtyRectsIndex= -1; +705 this.cDirtyRects= []; +706 +707 var cl= this.childrenList; +708 var cli; +709 for (var i = 0; i < cl.length; i++) { +710 cli= cl[i]; +711 var tt = cli.time - cli.start_time; +712 cli.animate(this, tt); +713 } +714 +715 return this; +716 }, +717 /** +718 * Add a rectangle to the list of dirty screen areas which should be redrawn. +719 * This is the opposite method to clear the whole screen and repaint everything again. +720 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this +721 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or +722 * even lowers performance under others, so it is a developer choice to activate them via a call to +723 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). +724 * +725 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping +726 * rectangles will be removed and intersecting ones will be unioned. +727 * +728 * Before calling this method, check if this.dirtyRectsEnabled is true. +729 * +730 * @param rectangle {CAAT.Rectangle} +731 */ +732 addDirtyRect : function( rectangle ) { +733 +734 if ( rectangle.isEmpty() ) { +735 return; +736 } +737 +738 var i, dr, j, drj; +739 var cdr= this.cDirtyRects; +740 +741 for( i=0; i<cdr.length; i++ ) { +742 dr= cdr[i]; +743 if ( !dr.isEmpty() && dr.intersects( rectangle ) ) { +744 var intersected= true; +745 while( intersected ) { +746 dr.unionRectangle( rectangle ); +747 +748 for( j=0; j<cdr.length; j++ ) { +749 if ( j!==i ) { +750 drj= cdr[j]; +751 if ( !drj.isEmpty() && drj.intersects( dr ) ) { +752 dr.unionRectangle( drj ); +753 drj.setEmpty(); +754 break; +755 } +756 } +757 } +758 +759 if ( j==cdr.length ) { +760 intersected= false; +761 } +762 } +763 +764 for( j=0; j<cdr.length; j++ ) { +765 if ( cdr[j].isEmpty() ) { +766 cdr.splice( j, 1 ); +767 } +768 } +769 +770 return; +771 } +772 } +773 +774 this.dirtyRectsIndex++; +775 +776 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { +777 for( i=0; i<32; i++ ) { +778 this.dirtyRects.push( new CAAT.Rectangle() ); +779 } +780 } +781 +782 var r= this.dirtyRects[ this.dirtyRectsIndex ]; +783 +784 r.x= rectangle.x; +785 r.y= rectangle.y; +786 r.x1= rectangle.x1; +787 r.y1= rectangle.y1; +788 r.width= rectangle.width; +789 r.height= rectangle.height; +790 +791 this.cDirtyRects.push( r ); +792 +793 }, +794 /** +795 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of +796 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from +797 * one to another, first of all an scene is drawn to offscreen, and that image is translated. +798 * <p> +799 * Until the creation of this method, both scenes where drawn while transitioning with +800 * its performance penalty since drawing two scenes could be twice as expensive than drawing +801 * only one. +802 * <p> +803 * Though a high performance increase, we should keep an eye on memory consumption. +804 * +805 * @param ctx a <code>canvas.getContext('2d')</code> instnce. +806 * @param scene {CAAT.Scene} the scene to draw offscreen. +807 */ +808 renderToContext : function(ctx, scene) { +809 /** +810 * draw actors on scene. +811 */ +812 if (scene.isInAnimationFrame(this.time)) { +813 ctx.globalAlpha = 1; +814 ctx.globalCompositeOperation = 'source-over'; +815 ctx.clearRect(0, 0, this.width, this.height); +816 ctx.setTransform(1,0,0, 0,1,0); +817 +818 var octx = this.ctx; +819 var ocrc = this.crc; +820 +821 this.ctx = this.crc = ctx; +822 ctx.save(); +823 +824 /** +825 * to draw an scene to an offscreen canvas, we have to: +826 * 1.- save diector's world model view matrix +827 * 2.- set no transformation on director since we want the offscreen to +828 * be drawn 1:1. +829 * 3.- set world dirty flag, so that the scene will recalculate its matrices +830 * 4.- animate the scene +831 * 5.- paint the scene +832 * 6.- restore world model view matrix. +833 */ +834 var matwmv= this.worldModelViewMatrix; +835 this.worldModelViewMatrix= new CAAT.Matrix(); +836 this.wdirty= true; +837 scene.animate(this, scene.time); +838 if ( scene.onRenderStart ) { +839 scene.onRenderStart(scene.time); +840 } +841 scene.paintActor(this, scene.time); +842 if ( scene.onRenderEnd ) { +843 scene.onRenderEnd(scene.time); +844 } +845 this.worldModelViewMatrix = matwmv; +846 +847 ctx.restore(); +848 +849 this.ctx = octx; +850 this.crc = ocrc; +851 } +852 }, +853 /** +854 * Add a new Scene to Director's Scene list. By adding a Scene to the Director +855 * does not mean it will be immediately visible, you should explicitly call either +856 * <ul> +857 * <li>easeIn +858 * <li>easeInOut +859 * <li>easeInOutRandom +860 * <li>setScene +861 * <li>or any of the scene switching methods +862 * </ul> +863 * +864 * @param scene {CAAT.Scene} an CAAT.Scene object. +865 */ +866 addScene : function(scene) { +867 scene.setBounds(0, 0, this.width, this.height); +868 this.scenes.push(scene); +869 scene.setEaseListener(this); +870 if (null === this.currentScene) { +871 this.setScene(0); +872 } +873 }, +874 /** +875 * Get the number of scenes contained in the Director. +876 * @return {number} the number of scenes contained in the Director. +877 */ +878 getNumScenes : function() { +879 return this.scenes.length; +880 }, +881 /** +882 * This method offers full control over the process of switching between any given two Scenes. +883 * To apply this method, you must specify the type of transition to apply for each Scene and +884 * the anchor to keep the Scene pinned at. +885 * <p> +886 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: +887 * <ul> +888 * <li>EASE_ROTATION +889 * <li>EASE_SCALE +890 * <li>EASE_TRANSLATION +891 * </ul> +892 * +893 * <p> +894 * The anchor will be any of these values defined in CAAT.Actor.prototype: +895 * <ul> +896 * <li>ANCHOR_CENTER +897 * <li>ANCHOR_TOP +898 * <li>ANCHOR_BOTTOM +899 * <li>ANCHOR_LEFT +900 * <li>ANCHOR_RIGHT +901 * <li>ANCHOR_TOP_LEFT +902 * <li>ANCHOR_TOP_RIGHT +903 * <li>ANCHOR_BOTTOM_LEFT +904 * <li>ANCHOR_BOTTOM_RIGHT +905 * </ul> +906 * +907 * <p> +908 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the +909 * point by which the scene will scaled. +910 * +911 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. +912 * @param typein integer indicating the type of transition to apply to the bringing in Scene. +913 * @param anchorin integer indicating the anchor of the bringing in Scene. +914 * @param outSceneIndex integer indicating the Scene index to take away from the Director. +915 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. +916 * @param anchorout integer indicating the anchor of the taking away Scene. +917 * @param time inteter indicating the time to perform the process of switchihg between Scene object +918 * in milliseconds. +919 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to +920 * the scenes. +921 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. +922 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. +923 */ +924 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { +925 +926 if (inSceneIndex === this.getCurrentSceneIndex()) { +927 return; +928 } +929 +930 var ssin = this.scenes[ inSceneIndex ]; +931 var sout = this.scenes[ outSceneIndex ]; +932 +933 if (!this.glEnabled && !navigator.browser==='iOS') { +934 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); +935 this.renderToContext(this.transitionScene.ctx, sout); +936 sout = this.transitionScene; +937 } +938 +939 ssin.setExpired(false); +940 sout.setExpired(false); +941 +942 ssin.mouseEnabled = false; +943 sout.mouseEnabled = false; +944 +945 ssin.resetTransform(); +946 sout.resetTransform(); +947 +948 ssin.setLocation(0, 0); +949 sout.setLocation(0, 0); +950 +951 ssin.alpha = 1; +952 sout.alpha = 1; +953 +954 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { +955 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); +956 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { +957 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); +958 } else { +959 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); +960 } +961 +962 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { +963 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); +964 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { +965 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); +966 } else { +967 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); +968 } +969 +970 this.childrenList = []; +971 +972 this.addChild(sout); +973 this.addChild(ssin); +974 }, +975 /** +976 * This method will switch between two given Scene indexes (ie, take away scene number 2, +977 * and bring in scene number 5). +978 * <p> +979 * It will randomly choose for each Scene the type of transition to apply and the anchor +980 * point of each transition type. +981 * <p> +982 * It will also set for different kind of transitions the following interpolators: +983 * <ul> +984 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +985 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +986 * <li>EASE_TRANSLATION -> BounceOutInterpolator +987 * </ul> +988 * +989 * <p> +990 * These are the default values, and could not be changed by now. +991 * This method in final instance delegates the process to easeInOutMethod. +992 * +993 * @see easeInOutMethod. +994 * +995 * @param inIndex integer indicating the entering scene index. +996 * @param outIndex integer indicating the exiting scene index. +997 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. +998 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. +999 */ +1000 easeInOutRandom : function(inIndex, outIndex, time, alpha) { +1001 +1002 var pin = Math.random(); +1003 var pout = Math.random(); +1004 +1005 var typeIn; +1006 var interpolatorIn; +1007 +1008 if (pin < 0.33) { +1009 typeIn = CAAT.Scene.prototype.EASE_ROTATION; +1010 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +1011 } else if (pin < 0.66) { +1012 typeIn = CAAT.Scene.prototype.EASE_SCALE; +1013 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); +1014 } else { +1015 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; +1016 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); +1017 } +1018 +1019 var typeOut; +1020 var interpolatorOut; +1021 +1022 if (pout < 0.33) { +1023 typeOut = CAAT.Scene.prototype.EASE_ROTATION; +1024 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +1025 } else if (pout < 0.66) { +1026 typeOut = CAAT.Scene.prototype.EASE_SCALE; +1027 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); +1028 } else { +1029 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; +1030 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); +1031 } +1032 +1033 this.easeInOut( +1034 inIndex, +1035 typeIn, +1036 (Math.random() * 8.99) >> 0, +1037 +1038 outIndex, +1039 typeOut, +1040 (Math.random() * 8.99) >> 0, +1041 +1042 time, +1043 alpha, +1044 +1045 interpolatorIn, +1046 interpolatorOut); +1047 +1048 }, +1049 /** +1050 * This method changes Director's current Scene to the scene index indicated by +1051 * inSceneIndex parameter. The Scene running in the director won't be eased out. +1052 * +1053 * @see {CAAT.Interpolator} +1054 * @see {CAAT.Actor} +1055 * @see {CAAT.Scene} +1056 * +1057 * @param inSceneIndex integer indicating the new Scene to set as current. +1058 * @param type integer indicating the type of transition to apply to bring the new current +1059 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, +1060 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. +1061 * @param time integer indicating how much time in milliseconds the Scene entrance will take. +1062 * @param alpha boolean indicating whether alpha transparency fading will be applied to the +1063 * entereing Scene. +1064 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of +1065 * CAAT.Actor.prototype.ANCHOR_* values. +1066 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to +1067 * apply. +1068 */ +1069 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { +1070 var sin = this.scenes[ inSceneIndex ]; +1071 if (type === CAAT.Scene.prototype.EASE_ROTATION) { +1072 sin.easeRotationIn(time, alpha, anchor, interpolator); +1073 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { +1074 sin.easeScaleIn(0, time, alpha, anchor, interpolator); +1075 } else { +1076 sin.easeTranslationIn(time, alpha, anchor, interpolator); +1077 } +1078 this.childrenList = []; +1079 this.addChild(sin); +1080 +1081 sin.resetTransform(); +1082 sin.setLocation(0, 0); +1083 sin.alpha = 1; +1084 sin.mouseEnabled = false; +1085 sin.setExpired(false); +1086 }, +1087 /** +1088 * Changes (or sets) the current Director scene to the index +1089 * parameter. There will be no transition on scene change. +1090 * @param sceneIndex {number} an integer indicating the index of the target Scene +1091 * to be shown. +1092 */ +1093 setScene : function(sceneIndex) { +1094 var sin = this.scenes[ sceneIndex ]; +1095 this.childrenList = []; +1096 this.addChild(sin); +1097 this.currentScene = sin; +1098 +1099 sin.setExpired(false); +1100 sin.mouseEnabled = true; +1101 sin.resetTransform(); +1102 sin.setLocation(0, 0); +1103 sin.alpha = 1; +1104 +1105 sin.activated(); +1106 }, +1107 /** +1108 * This method will change the current Scene by the Scene indicated as parameter. +1109 * It will apply random values for anchor and transition type. +1110 * @see easeInOutRandom +1111 * +1112 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. +1113 * @param time {number} an integer indicating the time the Scene transition will take. +1114 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1115 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1116 */ +1117 switchToScene : function(iNewSceneIndex, time, alpha, transition) { +1118 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1119 +1120 if (!transition) { +1121 this.setScene(iNewSceneIndex); +1122 } +1123 else { +1124 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); +1125 } +1126 }, +1127 /** +1128 * Sets the previous Scene in sequence as the current Scene. +1129 * @see switchToScene. +1130 * +1131 * @param time {number} integer indicating the time the Scene transition will take. +1132 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1133 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1134 */ +1135 switchToPrevScene : function(time, alpha, transition) { +1136 +1137 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1138 +1139 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { +1140 return; +1141 } +1142 +1143 if (!transition) { +1144 this.setScene(currentSceneIndex - 1); +1145 } +1146 else { +1147 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); +1148 } +1149 }, +1150 /** +1151 * Sets the previous Scene in sequence as the current Scene. +1152 * @see switchToScene. +1153 * +1154 * @param time {number} integer indicating the time the Scene transition will take. +1155 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1156 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1157 */ +1158 switchToNextScene: function(time, alpha, transition) { +1159 +1160 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1161 +1162 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { +1163 return; +1164 } +1165 +1166 if (!transition) { +1167 this.setScene(currentSceneIndex + 1); +1168 } +1169 else { +1170 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); +1171 } +1172 }, +1173 mouseEnter : function(mouseEvent) { +1174 }, +1175 mouseExit : function(mouseEvent) { +1176 }, +1177 mouseMove : function(mouseEvent) { +1178 }, +1179 mouseDown : function(mouseEvent) { +1180 }, +1181 mouseUp : function(mouseEvent) { +1182 }, +1183 mouseDrag : function(mouseEvent) { +1184 }, +1185 /** +1186 * Scene easing listener. Notifies scenes when they're about to be activated (set as current +1187 * director's scene). +1188 * +1189 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. +1190 * @param b_easeIn {boolean} scene enters or exits ? +1191 */ +1192 easeEnd : function(scene, b_easeIn) { +1193 // scene is going out +1194 if (!b_easeIn) { +1195 +1196 scene.setExpired(true); +1197 } else { +1198 this.currentScene = scene; +1199 this.currentScene.activated(); +1200 } +1201 +1202 scene.mouseEnabled = true; +1203 scene.emptyBehaviorList(); +1204 }, +1205 /** +1206 * Return the index for a given Scene object contained in the Director. +1207 * @param scene {CAAT.Scene} +1208 */ +1209 getSceneIndex : function(scene) { +1210 for (var i = 0; i < this.scenes.length; i++) { +1211 if (this.scenes[i] === scene) { +1212 return i; +1213 } +1214 } +1215 return -1; +1216 }, +1217 /** +1218 * Get a concrete director's scene. +1219 * @param index {number} an integer indicating the scene index. +1220 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. +1221 */ +1222 getScene : function(index) { +1223 return this.scenes[index]; +1224 }, +1225 /** +1226 * Return the index of the current scene in the Director's scene list. +1227 * @return {number} the current scene's index. +1228 */ +1229 getCurrentSceneIndex : function() { +1230 return this.getSceneIndex(this.currentScene); +1231 }, +1232 /** +1233 * Return the running browser name. +1234 * @return {string} the browser name. +1235 */ +1236 getBrowserName : function() { +1237 return this.browserInfo.browser; +1238 }, +1239 /** +1240 * Return the running browser version. +1241 * @return {string} the browser version. +1242 */ +1243 getBrowserVersion : function() { +1244 return this.browserInfo.version; +1245 }, +1246 /** +1247 * Return the operating system name. +1248 * @return {string} the os name. +1249 */ +1250 getOSName : function() { +1251 return this.browserInfo.OS; +1252 }, +1253 /** +1254 * Gets the resource with the specified resource name. +1255 * The Director holds a collection called <code>imagesCache</code> +1256 * where you can store a JSON of the form +1257 * <code>[ { id: imageId, image: imageObject } ]</code>. +1258 * This structure will be used as a resources cache. +1259 * There's a CAAT.ImagePreloader class to preload resources and +1260 * generate this structure on loading finalization. +1261 * +1262 * @param sId {object} an String identifying a resource. +1263 */ +1264 getImage : function(sId) { +1265 var ret = this.imagesCache[sId]; +1266 if (ret) { +1267 return ret; +1268 } +1269 +1270 for (var i = 0; i < this.imagesCache.length; i++) { +1271 if (this.imagesCache[i].id === sId) { +1272 return this.imagesCache[i].image; +1273 } +1274 } +1275 +1276 return null; +1277 }, +1278 /** +1279 * Adds an audio to the cache. +1280 * +1281 * @see CAAT.AudioManager.addAudio +1282 * @return this +1283 */ +1284 addAudio : function(id, url) { +1285 this.audioManager.addAudio(id, url); +1286 return this; +1287 }, +1288 /** +1289 * Plays the audio instance identified by the id. +1290 * @param id {object} the object used to store a sound in the audioCache. +1291 */ +1292 audioPlay : function(id) { +1293 this.audioManager.play(id); +1294 }, +1295 /** +1296 * Loops an audio instance identified by the id. +1297 * @param id {object} the object used to store a sound in the audioCache. +1298 * +1299 * @return {HTMLElement|null} the value from audioManager.loop +1300 */ +1301 audioLoop : function(id) { +1302 return this.audioManager.loop(id); +1303 }, +1304 endSound : function() { +1305 return this.audioManager.endSound(); +1306 }, +1307 setSoundEffectsEnabled : function(enabled) { +1308 return this.audioManager.setSoundEffectsEnabled(enabled); +1309 }, +1310 setMusicEnabled : function(enabled) { +1311 return this.audioManager.setMusicEnabled(enabled); +1312 }, +1313 isMusicEnabled : function() { +1314 return this.audioManager.isMusicEnabled(); +1315 }, +1316 isSoundEffectsEnabled : function() { +1317 return this.audioManager.isSoundEffectsEnabled(); +1318 }, +1319 setVolume : function( id, volume ) { +1320 return this.audioManager.setVolume( id, volume ); +1321 }, +1322 /** +1323 * Removes Director's scenes. +1324 */ +1325 emptyScenes : function() { +1326 this.scenes = []; +1327 }, +1328 /** +1329 * Adds an scene to this Director. +1330 * @param scene {CAAT.Scene} a scene object. +1331 */ +1332 addChild : function(scene) { +1333 scene.parent = this; +1334 this.childrenList.push(scene); +1335 }, +1336 /** +1337 * @Deprecated use CAAT.loop instead. +1338 * @param fps +1339 * @param callback +1340 * @param callback2 +1341 */ +1342 loop : function(fps,callback,callback2) { +1343 if ( callback2 ) { +1344 this.onRenderStart= callback; +1345 this.onRenderEnd= callback2; +1346 } else if (callback) { +1347 this.onRenderEnd= callback; +1348 } +1349 CAAT.loop(); +1350 }, +1351 /** +1352 * Starts the director animation.If no scene is explicitly selected, the current Scene will +1353 * be the first scene added to the Director. +1354 * <p> +1355 * The fps parameter will set the animation quality. Higher values, +1356 * means CAAT will try to render more frames in the same second (at the +1357 * expense of cpu power at least until hardware accelerated canvas rendering +1358 * context are available). A value of 60 is a high frame rate and should not be exceeded. +1359 * +1360 * @param fps {number} integer value indicating the target frames per second to run +1361 * the animation at. +1362 */ +1363 renderFrame : function(fps, callback) { +1364 var t = new Date().getTime(), +1365 delta = t - this.timeline; +1366 +1367 /* +1368 check for massive frame time. if for example the current browser tab is minified or taken out of +1369 foreground, the system will account for a bit time interval. minify that impact by lowering down +1370 the elapsed time (virtual timelines FTW) +1371 */ +1372 if ( delta > 500 ) { +1373 delta= 500; +1374 } +1375 +1376 if ( this.onRenderStart ) { +1377 this.onRenderStart(delta); +1378 } +1379 +1380 this.render(delta); +1381 +1382 if ( this.debugInfo ) { +1383 this.debugInfo(this.statistics); +1384 } +1385 +1386 this.timeline = t; +1387 +1388 if (this.onRenderEnd) { +1389 this.onRenderEnd(delta); +1390 } +1391 }, +1392 endLoop : function () { +1393 }, +1394 /** +1395 * This method states whether the director must clear background before rendering +1396 * each frame. +1397 * +1398 * The clearing method could be: +1399 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. +1400 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled +1401 * will have their areas redrawn. +1402 * + CAAT.Director.CLEAR_NONE. clears nothing. +1403 * +1404 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} +1405 * @return this. +1406 */ +1407 setClear : function(clear) { +1408 this.clear = clear; +1409 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { +1410 this.dirtyRectsEnabled= true; +1411 } +1412 return this; +1413 }, +1414 /** +1415 * Get this Director's AudioManager instance. +1416 * @return {CAAT.AudioManager} the AudioManager instance. +1417 */ +1418 getAudioManager : function() { +1419 return this.audioManager; +1420 }, +1421 /** +1422 * Acculumate dom elements position to properly offset on-screen mouse/touch events. +1423 * @param node +1424 */ +1425 cumulateOffset : function(node, parent, prop) { +1426 var left= prop+'Left'; +1427 var top= prop+'Top'; +1428 var x=0, y=0, style; +1429 +1430 while( navigator.browser!=='iOS' && node && node.style ) { +1431 if ( node.currentStyle ) { +1432 style= node.currentStyle['position']; +1433 } else { +1434 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); +1435 style= style ? style.getPropertyValue('position') : null; +1436 } +1437 +1438 // if (!/^(relative|absolute|fixed)$/.test(style)) { +1439 if (!/^(fixed)$/.test(style)) { +1440 x += node[left]; +1441 y+= node[top]; +1442 node = node[parent]; +1443 } else { +1444 break; +1445 } +1446 } +1447 +1448 return { +1449 x: x, +1450 y: y, +1451 style: style +1452 }; +1453 }, +1454 getOffset : function( node ) { +1455 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); +1456 if ( res.style==='fixed' ) { +1457 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); +1458 return { +1459 x: res.x + res2.x, +1460 y: res.y + res2.y +1461 }; +1462 } +1463 +1464 return { +1465 x: res.x, +1466 y: res.y +1467 }; +1468 }, +1469 /** +1470 * Normalize input event coordinates to be related to (0,0) canvas position. +1471 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. +1472 * @param e {MouseEvent} a mouse event from an input event. +1473 */ +1474 getCanvasCoord : function(point, e) { +1475 +1476 var posx = 0; +1477 var posy = 0; +1478 if (!e) e = window.event; +1479 +1480 if (e.pageX || e.pageY) { +1481 posx = e.pageX; +1482 posy = e.pageY; +1483 } +1484 else if (e.clientX || e.clientY) { +1485 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; +1486 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; +1487 } +1488 +1489 var offset= this.getOffset(e.target); +1490 +1491 posx-= offset.x; +1492 posy-= offset.y; +1493 +1494 ////////////// +1495 // transformar coordenada inversamente con affine transform de director. +1496 +1497 var pt= new CAAT.Point( posx, posy ); +1498 if ( !this.modelViewMatrixI ) { +1499 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); +1500 } +1501 this.modelViewMatrixI.transformCoord(pt); +1502 posx= pt.x; +1503 posy= pt.y 1504 -1505 }, -1506 -1507 __mouseDownHandler : function(e) { -1508 -1509 /* -1510 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no -1511 button was presses. Then, send a mouseUp for the previos actor, and return; -1512 */ -1513 if ( this.dragging && this.lastSelectedActor ) { -1514 this.__mouseUpHandler(e); -1515 return; -1516 } -1517 -1518 this.getCanvasCoord(this.mousePoint, e); -1519 this.isMouseDown = true; -1520 var lactor = this.findActorAtPosition(this.mousePoint); -1521 -1522 if (null !== lactor) { -1523 -1524 var pos = lactor.viewToModel( -1525 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1505 point.set(posx, posy); +1506 this.screenMousePoint.set(posx, posy); +1507 +1508 }, +1509 +1510 __mouseDownHandler : function(e) { +1511 +1512 /* +1513 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no +1514 button was presses. Then, send a mouseUp for the previos actor, and return; +1515 */ +1516 if ( this.dragging && this.lastSelectedActor ) { +1517 this.__mouseUpHandler(e); +1518 return; +1519 } +1520 +1521 this.getCanvasCoord(this.mousePoint, e); +1522 this.isMouseDown = true; +1523 var lactor = this.findActorAtPosition(this.mousePoint); +1524 +1525 if (null !== lactor) { 1526 -1527 lactor.mouseDown( -1528 new CAAT.MouseEvent().init( -1529 pos.x, -1530 pos.y, -1531 e, -1532 lactor, -1533 new CAAT.Point( -1534 this.screenMousePoint.x, -1535 this.screenMousePoint.y ))); -1536 } -1537 -1538 this.lastSelectedActor= lactor; -1539 }, +1527 var pos = lactor.viewToModel( +1528 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1529 +1530 lactor.mouseDown( +1531 new CAAT.MouseEvent().init( +1532 pos.x, +1533 pos.y, +1534 e, +1535 lactor, +1536 new CAAT.Point( +1537 this.screenMousePoint.x, +1538 this.screenMousePoint.y ))); +1539 } 1540 -1541 __mouseUpHandler : function(e) { -1542 -1543 this.isMouseDown = false; -1544 this.getCanvasCoord(this.mousePoint, e); +1541 this.lastSelectedActor= lactor; +1542 }, +1543 +1544 __mouseUpHandler : function(e) { 1545 -1546 var pos= null; -1547 var lactor= this.lastSelectedActor; +1546 this.isMouseDown = false; +1547 this.getCanvasCoord(this.mousePoint, e); 1548 -1549 if (null !== lactor) { -1550 pos = lactor.viewToModel( -1551 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1552 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { -1553 lactor.actionPerformed(e) -1554 } -1555 -1556 lactor.mouseUp( -1557 new CAAT.MouseEvent().init( -1558 pos.x, -1559 pos.y, -1560 e, -1561 lactor, -1562 this.screenMousePoint, -1563 this.currentScene.time)); -1564 } -1565 -1566 if (!this.dragging && null !== lactor) { -1567 if (lactor.contains(pos.x, pos.y)) { -1568 lactor.mouseClick( -1569 new CAAT.MouseEvent().init( -1570 pos.x, -1571 pos.y, -1572 e, -1573 lactor, -1574 this.screenMousePoint, -1575 this.currentScene.time)); -1576 } -1577 } -1578 -1579 this.dragging = false; -1580 this.in_= false; -1581 // CAAT.setCursor('default'); -1582 }, -1583 -1584 __mouseMoveHandler : function(e) { -1585 this.getCanvasCoord(this.mousePoint, e); +1549 var pos= null; +1550 var lactor= this.lastSelectedActor; +1551 +1552 if (null !== lactor) { +1553 pos = lactor.viewToModel( +1554 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1555 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { +1556 lactor.actionPerformed(e) +1557 } +1558 +1559 lactor.mouseUp( +1560 new CAAT.MouseEvent().init( +1561 pos.x, +1562 pos.y, +1563 e, +1564 lactor, +1565 this.screenMousePoint, +1566 this.currentScene.time)); +1567 } +1568 +1569 if (!this.dragging && null !== lactor) { +1570 if (lactor.contains(pos.x, pos.y)) { +1571 lactor.mouseClick( +1572 new CAAT.MouseEvent().init( +1573 pos.x, +1574 pos.y, +1575 e, +1576 lactor, +1577 this.screenMousePoint, +1578 this.currentScene.time)); +1579 } +1580 } +1581 +1582 this.dragging = false; +1583 this.in_= false; +1584 // CAAT.setCursor('default'); +1585 }, 1586 -1587 var lactor; -1588 var pos; +1587 __mouseMoveHandler : function(e) { +1588 this.getCanvasCoord(this.mousePoint, e); 1589 -1590 // drag -1591 -1592 if (this.isMouseDown && null !== this.lastSelectedActor) { -1593 /* -1594 // check for mouse move threshold. -1595 if (!this.dragging) { -1596 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && -1597 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { -1598 return; -1599 } -1600 } -1601 */ -1602 -1603 -1604 lactor = this.lastSelectedActor; -1605 pos = lactor.viewToModel( -1606 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1590 var lactor; +1591 var pos; +1592 +1593 var ct= this.currentScene ? this.currentScene.time : 0; +1594 +1595 // drag +1596 +1597 if (this.isMouseDown && null !== this.lastSelectedActor) { +1598 /* +1599 // check for mouse move threshold. +1600 if (!this.dragging) { +1601 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && +1602 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { +1603 return; +1604 } +1605 } +1606 */ 1607 -1608 this.dragging = true; -1609 -1610 var px= lactor.x; -1611 var py= lactor.y; -1612 lactor.mouseDrag( -1613 new CAAT.MouseEvent().init( -1614 pos.x, -1615 pos.y, -1616 e, -1617 lactor, -1618 new CAAT.Point( -1619 this.screenMousePoint.x, -1620 this.screenMousePoint.y), -1621 this.currentScene.time)); -1622 -1623 this.prevMousePoint.x= pos.x; -1624 this.prevMousePoint.y= pos.y; -1625 -1626 /** -1627 * Element has not moved after drag, so treat it as a button. -1628 */ -1629 if ( px===lactor.x && py===lactor.y ) { +1608 +1609 lactor = this.lastSelectedActor; +1610 pos = lactor.viewToModel( +1611 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1612 +1613 this.dragging = true; +1614 +1615 var px= lactor.x; +1616 var py= lactor.y; +1617 lactor.mouseDrag( +1618 new CAAT.MouseEvent().init( +1619 pos.x, +1620 pos.y, +1621 e, +1622 lactor, +1623 new CAAT.Point( +1624 this.screenMousePoint.x, +1625 this.screenMousePoint.y), +1626 ct)); +1627 +1628 this.prevMousePoint.x= pos.x; +1629 this.prevMousePoint.y= pos.y; 1630 -1631 var contains= lactor.contains(pos.x, pos.y); -1632 -1633 if (this.in_ && !contains) { -1634 lactor.mouseExit( -1635 new CAAT.MouseEvent().init( -1636 pos.x, -1637 pos.y, -1638 e, -1639 lactor, -1640 this.screenMousePoint, -1641 this.currentScene.time)); -1642 this.in_ = false; -1643 } -1644 -1645 if (!this.in_ && contains ) { -1646 lactor.mouseEnter( -1647 new CAAT.MouseEvent().init( -1648 pos.x, -1649 pos.y, -1650 e, -1651 lactor, -1652 this.screenMousePoint, -1653 this.currentScene.time)); -1654 this.in_ = true; -1655 } -1656 } -1657 -1658 return; -1659 } -1660 -1661 // mouse move. -1662 this.in_= true; -1663 -1664 lactor = this.findActorAtPosition(this.mousePoint); +1631 /** +1632 * Element has not moved after drag, so treat it as a button. +1633 */ +1634 if ( px===lactor.x && py===lactor.y ) { +1635 +1636 var contains= lactor.contains(pos.x, pos.y); +1637 +1638 if (this.in_ && !contains) { +1639 lactor.mouseExit( +1640 new CAAT.MouseEvent().init( +1641 pos.x, +1642 pos.y, +1643 e, +1644 lactor, +1645 this.screenMousePoint, +1646 ct)); +1647 this.in_ = false; +1648 } +1649 +1650 if (!this.in_ && contains ) { +1651 lactor.mouseEnter( +1652 new CAAT.MouseEvent().init( +1653 pos.x, +1654 pos.y, +1655 e, +1656 lactor, +1657 this.screenMousePoint, +1658 ct)); +1659 this.in_ = true; +1660 } +1661 } +1662 +1663 return; +1664 } 1665 -1666 // cambiamos de actor. -1667 if (lactor !== this.lastSelectedActor) { -1668 if (null !== this.lastSelectedActor) { -1669 -1670 pos = this.lastSelectedActor.viewToModel( -1671 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1672 -1673 this.lastSelectedActor.mouseExit( -1674 new CAAT.MouseEvent().init( -1675 pos.x, -1676 pos.y, -1677 e, -1678 this.lastSelectedActor, -1679 this.screenMousePoint, -1680 this.currentScene.time)); -1681 } -1682 -1683 if (null !== lactor) { -1684 pos = lactor.viewToModel( -1685 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1686 -1687 lactor.mouseEnter( -1688 new CAAT.MouseEvent().init( -1689 pos.x, -1690 pos.y, -1691 e, -1692 lactor, -1693 this.screenMousePoint, -1694 this.currentScene.time)); -1695 } -1696 } -1697 -1698 pos = lactor.viewToModel( -1699 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1700 -1701 if (null !== lactor) { +1666 // mouse move. +1667 this.in_= true; +1668 +1669 lactor = this.findActorAtPosition(this.mousePoint); +1670 +1671 // cambiamos de actor. +1672 if (lactor !== this.lastSelectedActor) { +1673 if (null !== this.lastSelectedActor) { +1674 +1675 pos = this.lastSelectedActor.viewToModel( +1676 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1677 +1678 this.lastSelectedActor.mouseExit( +1679 new CAAT.MouseEvent().init( +1680 pos.x, +1681 pos.y, +1682 e, +1683 this.lastSelectedActor, +1684 this.screenMousePoint, +1685 ct)); +1686 } +1687 +1688 if (null !== lactor) { +1689 pos = lactor.viewToModel( +1690 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1691 +1692 lactor.mouseEnter( +1693 new CAAT.MouseEvent().init( +1694 pos.x, +1695 pos.y, +1696 e, +1697 lactor, +1698 this.screenMousePoint, +1699 ct)); +1700 } +1701 } 1702 -1703 lactor.mouseMove( -1704 new CAAT.MouseEvent().init( -1705 pos.x, -1706 pos.y, -1707 e, -1708 lactor, -1709 this.screenMousePoint, -1710 this.currentScene.time)); -1711 } -1712 -1713 this.lastSelectedActor = lactor; -1714 }, -1715 -1716 __mouseOutHandler : function(e) { +1703 pos = lactor.viewToModel( +1704 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1705 +1706 if (null !== lactor) { +1707 +1708 lactor.mouseMove( +1709 new CAAT.MouseEvent().init( +1710 pos.x, +1711 pos.y, +1712 e, +1713 lactor, +1714 this.screenMousePoint, +1715 ct)); +1716 } 1717 -1718 if (null !== this.lastSelectedActor ) { -1719 -1720 this.getCanvasCoord(this.mousePoint, e); -1721 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); -1722 this.lastSelectedActor.viewToModel(pos); -1723 -1724 var ev= new CAAT.MouseEvent().init( -1725 pos.x, -1726 pos.y, -1727 e, -1728 this.lastSelectedActor, -1729 this.screenMousePoint, -1730 this.currentScene.time); -1731 -1732 this.lastSelectedActor.mouseExit(ev); -1733 this.lastSelectedActor.mouseOut(ev); -1734 -1735 if ( !this.dragging ) { -1736 this.lastSelectedActor = null; -1737 } -1738 } else { -1739 this.isMouseDown = false; -1740 this.in_ = false; -1741 } -1742 -1743 }, -1744 -1745 __mouseOverHandler : function(e) { -1746 -1747 var lactor; -1748 var pos, ev; -1749 this.getCanvasCoord(this.mousePoint, e); -1750 -1751 if ( null==this.lastSelectedActor ) { -1752 lactor= this.findActorAtPosition( this.mousePoint ); -1753 -1754 if (null !== lactor) { +1718 this.lastSelectedActor = lactor; +1719 }, +1720 +1721 __mouseOutHandler : function(e) { +1722 +1723 if (null !== this.lastSelectedActor ) { +1724 +1725 this.getCanvasCoord(this.mousePoint, e); +1726 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); +1727 this.lastSelectedActor.viewToModel(pos); +1728 +1729 var ev= new CAAT.MouseEvent().init( +1730 pos.x, +1731 pos.y, +1732 e, +1733 this.lastSelectedActor, +1734 this.screenMousePoint, +1735 this.currentScene.time); +1736 +1737 this.lastSelectedActor.mouseExit(ev); +1738 this.lastSelectedActor.mouseOut(ev); +1739 +1740 if ( !this.dragging ) { +1741 this.lastSelectedActor = null; +1742 } +1743 } else { +1744 this.isMouseDown = false; +1745 this.in_ = false; +1746 } +1747 +1748 }, +1749 +1750 __mouseOverHandler : function(e) { +1751 +1752 var lactor; +1753 var pos, ev; +1754 this.getCanvasCoord(this.mousePoint, e); 1755 -1756 pos = lactor.viewToModel( -1757 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1756 if ( null==this.lastSelectedActor ) { +1757 lactor= this.findActorAtPosition( this.mousePoint ); 1758 -1759 ev= new CAAT.MouseEvent().init( -1760 pos.x, -1761 pos.y, -1762 e, -1763 lactor, -1764 this.screenMousePoint, -1765 this.currentScene.time); -1766 -1767 lactor.mouseOver(ev); -1768 lactor.mouseEnter(ev); -1769 } -1770 -1771 this.lastSelectedActor= lactor; -1772 } else { -1773 lactor= this.lastSelectedActor; -1774 pos = lactor.viewToModel( -1775 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1776 -1777 ev= new CAAT.MouseEvent().init( -1778 pos.x, -1779 pos.y, -1780 e, -1781 lactor, -1782 this.screenMousePoint, -1783 this.currentScene.time); -1784 -1785 lactor.mouseOver(ev); -1786 lactor.mouseEnter(ev); -1787 -1788 } -1789 }, -1790 -1791 __mouseDBLClickHandler : function(e) { -1792 -1793 this.getCanvasCoord(this.mousePoint, e); -1794 if (null !== this.lastSelectedActor) { -1795 /* -1796 var pos = this.lastSelectedActor.viewToModel( -1797 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1798 */ -1799 this.lastSelectedActor.mouseDblClick( -1800 new CAAT.MouseEvent().init( -1801 this.mousePoint.x, -1802 this.mousePoint.y, -1803 e, -1804 this.lastSelectedActor, -1805 this.screenMousePoint, -1806 this.currentScene.time)); -1807 } -1808 }, -1809 -1810 /** -1811 * Same as mouseDown but not preventing event. -1812 * Will only take care of first touch. -1813 * @param e -1814 */ -1815 __touchStartHandler : function(e) { -1816 -1817 e.preventDefault(); -1818 e= e.targetTouches[0] -1819 this.__mouseDownHandler(e); -1820 }, +1759 if (null !== lactor) { +1760 +1761 pos = lactor.viewToModel( +1762 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1763 +1764 ev= new CAAT.MouseEvent().init( +1765 pos.x, +1766 pos.y, +1767 e, +1768 lactor, +1769 this.screenMousePoint, +1770 this.currentScane ? this.currentScene.time : 0); +1771 +1772 lactor.mouseOver(ev); +1773 lactor.mouseEnter(ev); +1774 } +1775 +1776 this.lastSelectedActor= lactor; +1777 } else { +1778 lactor= this.lastSelectedActor; +1779 pos = lactor.viewToModel( +1780 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1781 +1782 ev= new CAAT.MouseEvent().init( +1783 pos.x, +1784 pos.y, +1785 e, +1786 lactor, +1787 this.screenMousePoint, +1788 this.currentScene.time); +1789 +1790 lactor.mouseOver(ev); +1791 lactor.mouseEnter(ev); +1792 +1793 } +1794 }, +1795 +1796 __mouseDBLClickHandler : function(e) { +1797 +1798 this.getCanvasCoord(this.mousePoint, e); +1799 if (null !== this.lastSelectedActor) { +1800 /* +1801 var pos = this.lastSelectedActor.viewToModel( +1802 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1803 */ +1804 this.lastSelectedActor.mouseDblClick( +1805 new CAAT.MouseEvent().init( +1806 this.mousePoint.x, +1807 this.mousePoint.y, +1808 e, +1809 this.lastSelectedActor, +1810 this.screenMousePoint, +1811 this.currentScene.time)); +1812 } +1813 }, +1814 +1815 /** +1816 * Same as mouseDown but not preventing event. +1817 * Will only take care of first touch. +1818 * @param e +1819 */ +1820 __touchStartHandler : function(e) { 1821 -1822 __touchEndHandler : function(e) { -1823 -1824 e.preventDefault(); -1825 e= e.changedTouches[0]; -1826 this.__mouseUpHandler(e); -1827 }, +1822 e.preventDefault(); +1823 e= e.targetTouches[0] +1824 this.__mouseDownHandler(e); +1825 }, +1826 +1827 __touchEndHandler : function(e) { 1828 -1829 __touchMoveHandler : function(e) { -1830 -1831 e.preventDefault(); -1832 -1833 if ( this.gesturing ) { -1834 return; -1835 } -1836 -1837 for( var i=0; i<e.targetTouches.length; i++ ) { -1838 if ( !i ) { -1839 this.__mouseMoveHandler(e.targetTouches[i]); -1840 } -1841 } -1842 }, -1843 -1844 __gestureStart : function( scale, rotation ) { -1845 this.gesturing= true; -1846 this.__gestureRotation= this.lastSelectedActor.rotationAngle; -1847 this.__gestureSX= this.lastSelectedActor.scaleX - 1; -1848 this.__gestureSY= this.lastSelectedActor.scaleY - 1; -1849 }, -1850 -1851 __gestureChange : function( scale, rotation ) { -1852 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { -1853 return; -1854 } +1829 e.preventDefault(); +1830 e= e.changedTouches[0]; +1831 this.__mouseUpHandler(e); +1832 }, +1833 +1834 __touchMoveHandler : function(e) { +1835 +1836 e.preventDefault(); +1837 +1838 if ( this.gesturing ) { +1839 return; +1840 } +1841 +1842 for( var i=0; i<e.targetTouches.length; i++ ) { +1843 if ( !i ) { +1844 this.__mouseMoveHandler(e.targetTouches[i]); +1845 } +1846 } +1847 }, +1848 +1849 __gestureStart : function( scale, rotation ) { +1850 this.gesturing= true; +1851 this.__gestureRotation= this.lastSelectedActor.rotationAngle; +1852 this.__gestureSX= this.lastSelectedActor.scaleX - 1; +1853 this.__gestureSY= this.lastSelectedActor.scaleY - 1; +1854 }, 1855 -1856 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { -1857 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); -1858 -1859 this.lastSelectedActor.setScale( -1860 this.__gestureSX + scale, -1861 this.__gestureSY + scale ); -1862 } +1856 __gestureChange : function( scale, rotation ) { +1857 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { +1858 return; +1859 } +1860 +1861 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { +1862 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); 1863 -1864 }, -1865 -1866 __gestureEnd : function( scale, rotation ) { -1867 this.gesturing= false; -1868 this.__gestureRotation= 0; -1869 this.__gestureScale= 0; -1870 }, -1871 -1872 addHandlers: function(canvas) { -1873 -1874 var me= this; -1875 -1876 canvas.addEventListener('mouseup', function(e) { -1877 e.preventDefault(); -1878 me.__mouseUpHandler(e); -1879 }, false ); +1864 this.lastSelectedActor.setScale( +1865 this.__gestureSX + scale, +1866 this.__gestureSY + scale ); +1867 } +1868 +1869 }, +1870 +1871 __gestureEnd : function( scale, rotation ) { +1872 this.gesturing= false; +1873 this.__gestureRotation= 0; +1874 this.__gestureScale= 0; +1875 }, +1876 +1877 addHandlers: function(canvas) { +1878 +1879 var me= this; 1880 -1881 canvas.addEventListener('mousedown', function(e) { +1881 canvas.addEventListener('mouseup', function(e) { 1882 e.preventDefault(); -1883 me.__mouseDownHandler(e); +1883 me.__mouseUpHandler(e); 1884 }, false ); 1885 -1886 canvas.addEventListener('mouseover',function(e) { +1886 canvas.addEventListener('mousedown', function(e) { 1887 e.preventDefault(); -1888 me.__mouseOverHandler(e); -1889 }, false); +1888 me.__mouseDownHandler(e); +1889 }, false ); 1890 -1891 canvas.addEventListener('mouseout',function(e) { +1891 canvas.addEventListener('mouseover',function(e) { 1892 e.preventDefault(); -1893 me.__mouseOutHandler(e); +1893 me.__mouseOverHandler(e); 1894 }, false); 1895 -1896 canvas.addEventListener('mousemove', -1897 function(e) { -1898 e.preventDefault(); -1899 me.__mouseMoveHandler(e); -1900 }, -1901 false); -1902 -1903 canvas.addEventListener("dblclick", function(e) { -1904 e.preventDefault(); -1905 me.__mouseDBLClickHandler(e); -1906 }, false); +1896 canvas.addEventListener('mouseout',function(e) { +1897 e.preventDefault(); +1898 me.__mouseOutHandler(e); +1899 }, false); +1900 +1901 canvas.addEventListener('mousemove', +1902 function(e) { +1903 e.preventDefault(); +1904 me.__mouseMoveHandler(e); +1905 }, +1906 false); 1907 -1908 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); -1909 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); -1910 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); -1911 canvas.addEventListener("gesturestart", function(e) { -1912 e.preventDefault(); -1913 me.__gestureStart( e.scale, e.rotation ); -1914 }, false ); -1915 canvas.addEventListener("gestureend", function(e) { -1916 e.preventDefault(); -1917 me.__gestureEnd( e.scale, e.rotation ); -1918 }, false ); -1919 canvas.addEventListener("gesturechange", function(e) { -1920 e.preventDefault(); -1921 me.__gestureChange( e.scale, e.rotation ); -1922 }, false ); -1923 }, -1924 -1925 enableEvents : function( onElement ) { -1926 CAAT.RegisterDirector(this); -1927 this.in_ = false; -1928 this.createEventHandler( onElement ); -1929 }, -1930 -1931 createEventHandler : function( onElement ) { -1932 //var canvas= this.canvas; -1933 this.in_ = false; -1934 //this.addHandlers(canvas); -1935 this.addHandlers( onElement ); -1936 } -1937 }; -1938 -1939 -1940 if (CAAT.__CSS__) { -1941 -1942 CAAT.Director.prototype.clip= true; -1943 CAAT.Director.prototype.glEnabled= false; +1908 canvas.addEventListener("dblclick", function(e) { +1909 e.preventDefault(); +1910 me.__mouseDBLClickHandler(e); +1911 }, false); +1912 +1913 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); +1914 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); +1915 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); +1916 canvas.addEventListener("gesturestart", function(e) { +1917 e.preventDefault(); +1918 me.__gestureStart( e.scale, e.rotation ); +1919 }, false ); +1920 canvas.addEventListener("gestureend", function(e) { +1921 e.preventDefault(); +1922 me.__gestureEnd( e.scale, e.rotation ); +1923 }, false ); +1924 canvas.addEventListener("gesturechange", function(e) { +1925 e.preventDefault(); +1926 me.__gestureChange( e.scale, e.rotation ); +1927 }, false ); +1928 }, +1929 +1930 enableEvents : function( onElement ) { +1931 CAAT.RegisterDirector(this); +1932 this.in_ = false; +1933 this.createEventHandler( onElement ); +1934 }, +1935 +1936 createEventHandler : function( onElement ) { +1937 //var canvas= this.canvas; +1938 this.in_ = false; +1939 //this.addHandlers(canvas); +1940 this.addHandlers( onElement ); +1941 } +1942 }; +1943 1944 -1945 CAAT.Director.prototype.getRenderType= function() { -1946 return 'CSS'; -1947 }; -1948 -1949 CAAT.Director.prototype.setScaleProportional= function(w,h) { -1950 -1951 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); -1952 this.setScaleAnchored( factor, factor, 0, 0 ); +1945 if (CAAT.__CSS__) { +1946 +1947 CAAT.Director.prototype.clip= true; +1948 CAAT.Director.prototype.glEnabled= false; +1949 +1950 CAAT.Director.prototype.getRenderType= function() { +1951 return 'CSS'; +1952 }; 1953 -1954 this.eventHandler.style.width= ''+this.referenceWidth +'px'; -1955 this.eventHandler.style.height= ''+this.referenceHeight+'px'; -1956 }; -1957 -1958 CAAT.Director.prototype.setBounds= function(x, y, w, h) { -1959 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); -1960 for (var i = 0; i < this.scenes.length; i++) { -1961 this.scenes[i].setBounds(0, 0, w, h); -1962 } -1963 this.eventHandler.style.width= w+'px'; -1964 this.eventHandler.style.height= h+'px'; -1965 -1966 return this; -1967 }; -1968 -1969 /** -1970 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most -1971 * div in the document hierarchy (z-index 999999). -1972 * @param width -1973 * @param height -1974 * @param domElement -1975 * @param proxy -1976 */ -1977 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { -1978 -1979 this.timeline = new Date().getTime(); -1980 this.domElement= domElement; -1981 this.style('position','absolute'); -1982 this.style('width',''+width+'px'); -1983 this.style('height',''+height+'px'); -1984 this.style('overflow', 'hidden' ); -1985 -1986 this.enableEvents(domElement); -1987 -1988 this.setBounds(0, 0, width, height); -1989 -1990 this.checkDebug(); -1991 return this; -1992 }; -1993 -1994 CAAT.Director.prototype.render= function(time) { -1995 -1996 this.time += time; -1997 this.animate(this,time); +1954 CAAT.Director.prototype.setScaleProportional= function(w,h) { +1955 +1956 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); +1957 this.setScaleAnchored( factor, factor, 0, 0 ); +1958 +1959 this.eventHandler.style.width= ''+this.referenceWidth +'px'; +1960 this.eventHandler.style.height= ''+this.referenceHeight+'px'; +1961 }; +1962 +1963 CAAT.Director.prototype.setBounds= function(x, y, w, h) { +1964 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); +1965 for (var i = 0; i < this.scenes.length; i++) { +1966 this.scenes[i].setBounds(0, 0, w, h); +1967 } +1968 this.eventHandler.style.width= w+'px'; +1969 this.eventHandler.style.height= h+'px'; +1970 +1971 return this; +1972 }; +1973 +1974 /** +1975 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most +1976 * div in the document hierarchy (z-index 999999). +1977 * @param width +1978 * @param height +1979 * @param domElement +1980 * @param proxy +1981 */ +1982 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { +1983 +1984 this.timeline = new Date().getTime(); +1985 this.domElement= domElement; +1986 this.style('position','absolute'); +1987 this.style('width',''+width+'px'); +1988 this.style('height',''+height+'px'); +1989 this.style('overflow', 'hidden' ); +1990 +1991 this.enableEvents(domElement); +1992 +1993 this.setBounds(0, 0, width, height); +1994 +1995 this.checkDebug(); +1996 return this; +1997 }; 1998 -1999 /** -2000 * draw director active scenes. -2001 */ -2002 var i, l, tt; +1999 CAAT.Director.prototype.render= function(time) { +2000 +2001 this.time += time; +2002 this.animate(this,time); 2003 -2004 if ( CAAT.DEBUG ) { -2005 this.resetStats(); -2006 } -2007 -2008 for (i = 0, l=this.childrenList.length; i < l; i++) { -2009 var c= this.childrenList[i]; -2010 if (c.isInAnimationFrame(this.time)) { -2011 tt = c.time - c.start_time; -2012 if ( c.onRenderStart ) { -2013 c.onRenderStart(tt); -2014 } -2015 -2016 if ( c.onRenderEnd ) { -2017 c.onRenderEnd(tt); -2018 } -2019 -2020 if (!c.isPaused()) { -2021 c.time += time; -2022 } -2023 -2024 if ( CAAT.DEBUG ) { -2025 this.statistics.size_total+= c.size_total; -2026 this.statistics.size_active+= c.size_active; -2027 this.statistics.size_dirtyRects= this.nDirtyRects; -2028 } -2029 -2030 } -2031 } -2032 -2033 this.frameCounter++; -2034 }; -2035 -2036 CAAT.Director.prototype.addScene= function(scene) { -2037 scene.setVisible(true); -2038 scene.setBounds(0, 0, this.width, this.height); -2039 this.scenes.push(scene); -2040 scene.setEaseListener(this); -2041 if (null === this.currentScene) { -2042 this.setScene(0); -2043 } -2044 -2045 this.domElement.appendChild( scene.domElement ); -2046 }; -2047 -2048 CAAT.Director.prototype.emptyScenes= function() { -2049 this.scenes = []; -2050 this.domElement.innerHTML=''; -2051 this.createEventHandler(); -2052 }; -2053 -2054 CAAT.Director.prototype.setClear= function(clear) { -2055 return this; -2056 }; -2057 -2058 CAAT.Director.prototype.createEventHandler= function() { -2059 this.eventHandler= document.createElement('div'); -2060 this.domElement.appendChild(this.eventHandler); -2061 -2062 this.eventHandler.style.position= 'absolute'; -2063 this.eventHandler.style.left= '0'; -2064 this.eventHandler.style.top= '0'; -2065 this.eventHandler.style.zIndex= 999999; -2066 this.eventHandler.style.width= ''+this.width+'px'; -2067 this.eventHandler.style.height= ''+this.height+'px'; -2068 -2069 var canvas= this.eventHandler; -2070 this.in_ = false; -2071 -2072 this.addHandlers(canvas); -2073 }; -2074 } -2075 -2076 extend(CAAT.Director, CAAT.ActorContainer, null); -2077 })(); -2078 \ No newline at end of file +2004 /** +2005 * draw director active scenes. +2006 */ +2007 var i, l, tt; +2008 +2009 if ( CAAT.DEBUG ) { +2010 this.resetStats(); +2011 } +2012 +2013 for (i = 0, l=this.childrenList.length; i < l; i++) { +2014 var c= this.childrenList[i]; +2015 if (c.isInAnimationFrame(this.time)) { +2016 tt = c.time - c.start_time; +2017 if ( c.onRenderStart ) { +2018 c.onRenderStart(tt); +2019 } +2020 +2021 if ( c.onRenderEnd ) { +2022 c.onRenderEnd(tt); +2023 } +2024 +2025 if (!c.isPaused()) { +2026 c.time += time; +2027 } +2028 +2029 if ( CAAT.DEBUG ) { +2030 this.statistics.size_total+= c.size_total; +2031 this.statistics.size_active+= c.size_active; +2032 this.statistics.size_dirtyRects= this.nDirtyRects; +2033 } +2034 +2035 } +2036 } +2037 +2038 this.frameCounter++; +2039 }; +2040 +2041 CAAT.Director.prototype.addScene= function(scene) { +2042 scene.setVisible(true); +2043 scene.setBounds(0, 0, this.width, this.height); +2044 this.scenes.push(scene); +2045 scene.setEaseListener(this); +2046 if (null === this.currentScene) { +2047 this.setScene(0); +2048 } +2049 +2050 this.domElement.appendChild( scene.domElement ); +2051 }; +2052 +2053 CAAT.Director.prototype.emptyScenes= function() { +2054 this.scenes = []; +2055 this.domElement.innerHTML=''; +2056 this.createEventHandler(); +2057 }; +2058 +2059 CAAT.Director.prototype.setClear= function(clear) { +2060 return this; +2061 }; +2062 +2063 CAAT.Director.prototype.createEventHandler= function() { +2064 this.eventHandler= document.createElement('div'); +2065 this.domElement.appendChild(this.eventHandler); +2066 +2067 this.eventHandler.style.position= 'absolute'; +2068 this.eventHandler.style.left= '0'; +2069 this.eventHandler.style.top= '0'; +2070 this.eventHandler.style.zIndex= 999999; +2071 this.eventHandler.style.width= ''+this.width+'px'; +2072 this.eventHandler.style.height= ''+this.height+'px'; +2073 +2074 var canvas= this.eventHandler; +2075 this.in_ = false; +2076 +2077 this.addHandlers(canvas); +2078 }; +2079 } +2080 +2081 extend(CAAT.Director, CAAT.ActorContainer, null); +2082 })(); +2083 \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_scene.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_scene.js.html index d148d78c..c077d07f 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_scene.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_scene.js.html @@ -497,8 +497,124 @@ 490 ctx.fillStyle= this.fillStyle; 491 ctx.fillRect(0,0,this.width,this.height ); 492 } -493 } -494 }; -495 -496 extend( CAAT.Scene, CAAT.ActorContainer ); -497 })(); \ No newline at end of file +493 }, +494 /** +495 * Find a pointed actor at position point. +496 * This method tries lo find the correctly pointed actor in two different ways. +497 * + first of all, if inputList is defined, it will look for an actor in it. +498 * + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. +499 * @param point <CAAT.Point> +500 */ +501 findActorAtPosition : function(point) { +502 var i,j; +503 +504 var p= new CAAT.Point(); +505 +506 if ( this.inputList ) { +507 var il= this.inputList; +508 for( i=0; i<il.length; i++ ) { +509 var ill= il[i]; +510 for( j=0; j<ill.length; j++ ) { +511 p.set(point.x, point.y); +512 var modelViewMatrixI= ill[j].worldModelViewMatrix.getInverse(); +513 modelViewMatrixI.transformCoord(p); +514 if ( ill[j].contains(p.x, p.y) ) { +515 return ill[j]; +516 } +517 } +518 } +519 } +520 +521 p.set(point.x, point.y); +522 return CAAT.Scene.superclass.findActorAtPosition.call(this,p); +523 }, +524 +525 /** +526 * Enable a number of input lists. +527 * These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed +528 * actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance. +529 * The system will traverse the whole lists in order trying to find a pointed actor. +530 * +531 * Elements are added to each list either in head or tail. +532 * +533 * @param size <number> number of lists. +534 */ +535 enableInputList : function( size ) { +536 this.inputList= []; +537 for( var i=0; i<size; i++ ) { +538 this.inputList.push([]); +539 } +540 +541 return this; +542 }, +543 +544 /** +545 * Add an actor to a given inputList. +546 * @param actor <CAAT.Actor> an actor instance +547 * @param index <number> the inputList index to add the actor to. This value will be clamped to the number of +548 * available lists. +549 * @param position <number> the position on the selected inputList to add the actor at. This value will be +550 * clamped to the number of available lists. +551 */ +552 addActorToInputList : function( actor, index, position ) { +553 if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1; +554 var il= this.inputList[index]; +555 +556 if ( typeof position==="undefined" || position>=il.length ) { +557 il.push( actor ); +558 } else if (position<=0) { +559 il.unshift( actor ); +560 } else { +561 il.splice( position, 0, actor ); +562 } +563 +564 return this; +565 }, +566 +567 /** +568 * Remove all elements from an input list. +569 * @param index <number> the inputList index to add the actor to. This value will be clamped to the number of +570 * available lists so take care when emptying a non existant inputList index since you could end up emptying +571 * an undesired input list. +572 */ +573 emptyInputList : function( index ) { +574 if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1; +575 this.inputList[index]= []; +576 return this; +577 }, +578 +579 /** +580 * remove an actor from a given input list index. +581 * If no index is supplied, the actor will be removed from every input list. +582 * @param actor <CAAT.Actor> +583 * @param index <!number> an optional input list index. This value will be clamped to the number of +584 * available lists. +585 */ +586 removeActorFromInputList : function( actor, index ) { +587 if ( typeof index==="undefined" ) { +588 var i,j; +589 for( i=0; i<this.inputList.length; i++ ) { +590 var il= this.inputList[i]; +591 for( j=0; j<il.length; j++ ) { +592 if ( il[j]==actor ) { +593 il.splice( j,1 ); +594 } +595 } +596 } +597 return this; +598 } +599 +600 if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1; +601 var il= this.inputList[index]; +602 for( j=0; j<il.length; j++ ) { +603 if ( il[j]==actor ) { +604 il.splice( j,1 ); +605 } +606 } +607 +608 return this; +609 } +610 }; +611 +612 extend( CAAT.Scene, CAAT.ActorContainer ); +613 })(); \ No newline at end of file diff --git a/src/model/director.js b/src/model/director.js index 8fff17a7..ba7bd7ef 100644 --- a/src/model/director.js +++ b/src/model/director.js @@ -1495,6 +1495,9 @@ // transformar coordenada inversamente con affine transform de director. var pt= new CAAT.Point( posx, posy ); + if ( !this.modelViewMatrixI ) { + this.modelViewMatrixI= this.modelViewMatrix.getInverse(); + } this.modelViewMatrixI.transformCoord(pt); posx= pt.x; posy= pt.y @@ -1587,6 +1590,8 @@ var lactor; var pos; + var ct= this.currentScene ? this.currentScene.time : 0; + // drag if (this.isMouseDown && null !== this.lastSelectedActor) { @@ -1618,7 +1623,7 @@ new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y), - this.currentScene.time)); + ct)); this.prevMousePoint.x= pos.x; this.prevMousePoint.y= pos.y; @@ -1638,7 +1643,7 @@ e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = false; } @@ -1650,7 +1655,7 @@ e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); this.in_ = true; } } @@ -1677,7 +1682,7 @@ e, this.lastSelectedActor, this.screenMousePoint, - this.currentScene.time)); + ct)); } if (null !== lactor) { @@ -1691,7 +1696,7 @@ e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } } @@ -1707,7 +1712,7 @@ e, lactor, this.screenMousePoint, - this.currentScene.time)); + ct)); } this.lastSelectedActor = lactor; @@ -1762,7 +1767,7 @@ e, lactor, this.screenMousePoint, - this.currentScene.time); + this.currentScane ? this.currentScene.time : 0); lactor.mouseOver(ev); lactor.mouseEnter(ev);