Skip to content

Commit

Permalink
02/23/2012 *0.3 Build 208*
Browse files Browse the repository at this point in the history
--------------------------

* Added to CAAT.Scene the following methods:
   + findActorAtPosition(CAAT.Point) : custom actor find procedure. This is overriden to attend at the priority input lists.
   + enableInputList(number) :  number of priority lists to set for this scene. A priority list is a list of actors to
                                which are suitable to receive input first. If no actor on the priority lists are under
                                the cursor, the whole scene graph is traversed instead.
   + addActorToInputList( actor, index, position ) : add an actor to a given priority list at certain position.
   + emptyInputList( index ) : remove all elements from a list.
   + removeActorFromInputList( actor, index ) : remove an actor from a list, or if no index list is supplied remove
       the actor from every list in which appears.
* Fixed Actor.setImageTransformation( CAAT.SpriteImage.prototype.TR_TILE ) which didn't honor actor position and offset
  to appropriately place the tiling image. Also the performance sink when using this flag with huge actors's been fixed.
  • Loading branch information
hyperandroid committed Feb 23, 2012
1 parent 1a77f74 commit 11cad28
Show file tree
Hide file tree
Showing 18 changed files with 3,857 additions and 3,469 deletions.
6 changes: 3 additions & 3 deletions build/caat-box2d-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/caat-box2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 181
Version: 0.3 build: 209
Created on:
DATE: 2012-02-20
TIME: 23:55:34
DATE: 2012-02-23
TIME: 17:04:10
*/


Expand Down
93 changes: 47 additions & 46 deletions build/caat-css-min.js

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions build/caat-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 181
Version: 0.3 build: 209
Created on:
DATE: 2012-02-20
TIME: 23:55:34
DATE: 2012-02-23
TIME: 17:04:09
*/


Expand Down Expand Up @@ -8871,6 +8871,7 @@ var cp1= proxy(
*/
animate : function(director, time) {
this.setModelViewMatrix(this);
this.modelViewMatrixI= this.modelViewMatrix.getInverse();
this.setScreenBounds();

this.dirty= false;
Expand Down Expand Up @@ -9669,7 +9670,6 @@ var cp1= proxy(
// transformar coordenada inversamente con affine transform de director.

var pt= new CAAT.Point( posx, posy );
this.modelViewMatrixI= this.modelViewMatrix.getInverse();
this.modelViewMatrixI.transformCoord(pt);
posx= pt.x;
posy= pt.y
Expand Down Expand Up @@ -11047,29 +11047,32 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) {
this.setSpriteIndexAtTime(time);
var el= this.mapInfo[this.spriteIndex];

var r= new CAAT.Rectangle();
this.ownerActor.AABB.intersect( director.AABB, r );

var w= this.getWidth();
var h= this.getHeight();
var xoff= this.offsetX % w;
var xoff= (this.offsetX-this.ownerActor.x) % w;
if ( xoff> 0 ) {
xoff= xoff-w;
}
var yoff= this.offsetY % h;
var yoff= (this.offsetY-this.ownerActor.y) % h;
if ( yoff> 0 ) {
yoff= yoff-h;
}

var nw= (((this.ownerActor.width-xoff)/w)>>0)+1;
var nh= (((this.ownerActor.height-yoff)/h)>>0)+1;
var nw= (((r.width-xoff)/w)>>0)+1;
var nh= (((r.height-yoff)/h)>>0)+1;
var i,j;
var ctx= director.ctx;

for( i=0; i<nh; i++ ) {
for( j=0; j<nw; j++ ) {
director.ctx.drawImage(
ctx.drawImage(
this.image,
el.x, el.y,
el.width, el.height,
(x+xoff+j*el.width)>>0, (y+yoff+i*el.height)>>0,
(r.x-this.ownerActor.x+xoff+j*el.width)>>0, (r.y-this.ownerActor.y+yoff+i*el.height)>>0,
el.width, el.height);
}
}
Expand Down
107 changes: 55 additions & 52 deletions build/caat-min.js

Large diffs are not rendered by default.

142 changes: 130 additions & 12 deletions build/caat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 181
Version: 0.3 build: 209

Created on:
DATE: 2012-02-20
TIME: 23:55:33
DATE: 2012-02-23
TIME: 17:04:09
*/


Expand Down Expand Up @@ -6284,7 +6284,7 @@ var cp1= proxy(
* @return null if the point is not inside the Actor. The Actor otherwise.
*/
findActorAtPosition : function(point) {
if ( !this.mouseEnabled || !this.isInAnimationFrame(this.time) ) {
if ( !this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time) ) {
return null;
}

Expand Down Expand Up @@ -7232,7 +7232,6 @@ var cp1= proxy(
cl[i].drawScreenBoundingBox(director,time);
}
CAAT.ActorContainer.superclass.drawScreenBoundingBox.call(this,director,time);

},
/**
* Removes all children from this ActorContainer.
Expand Down Expand Up @@ -9884,6 +9883,7 @@ var cp1= proxy(
*/
animate : function(director, time) {
this.setModelViewMatrix(this);
this.modelViewMatrixI= this.modelViewMatrix.getInverse();
this.setScreenBounds();

this.dirty= false;
Expand Down Expand Up @@ -10682,7 +10682,6 @@ var cp1= proxy(
// transformar coordenada inversamente con affine transform de director.

var pt= new CAAT.Point( posx, posy );
this.modelViewMatrixI= this.modelViewMatrix.getInverse();
this.modelViewMatrixI.transformCoord(pt);
posx= pt.x;
posy= pt.y
Expand Down Expand Up @@ -12060,29 +12059,32 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) {
this.setSpriteIndexAtTime(time);
var el= this.mapInfo[this.spriteIndex];

var r= new CAAT.Rectangle();
this.ownerActor.AABB.intersect( director.AABB, r );

var w= this.getWidth();
var h= this.getHeight();
var xoff= this.offsetX % w;
var xoff= (this.offsetX-this.ownerActor.x) % w;
if ( xoff> 0 ) {
xoff= xoff-w;
}
var yoff= this.offsetY % h;
var yoff= (this.offsetY-this.ownerActor.y) % h;
if ( yoff> 0 ) {
yoff= yoff-h;
}

var nw= (((this.ownerActor.width-xoff)/w)>>0)+1;
var nh= (((this.ownerActor.height-yoff)/h)>>0)+1;
var nw= (((r.width-xoff)/w)>>0)+1;
var nh= (((r.height-yoff)/h)>>0)+1;
var i,j;
var ctx= director.ctx;

for( i=0; i<nh; i++ ) {
for( j=0; j<nw; j++ ) {
director.ctx.drawImage(
ctx.drawImage(
this.image,
el.x, el.y,
el.width, el.height,
(x+xoff+j*el.width)>>0, (y+yoff+i*el.height)>>0,
(r.x-this.ownerActor.x+xoff+j*el.width)>>0, (r.y-this.ownerActor.y+yoff+i*el.height)>>0,
el.width, el.height);
}
}
Expand Down Expand Up @@ -13293,6 +13295,122 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) {
ctx.fillStyle= this.fillStyle;
ctx.fillRect(0,0,this.width,this.height );
}
},
/**
* Find a pointed actor at position point.
* This method tries lo find the correctly pointed actor in two different ways.
* + first of all, if inputList is defined, it will look for an actor in it.
* + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor.
* @param point <CAAT.Point>
*/
findActorAtPosition : function(point) {
var i,j;

var p= new CAAT.Point();

if ( this.inputList ) {
var il= this.inputList;
for( i=0; i<il.length; i++ ) {
var ill= il[i];
for( j=0; j<ill.length; j++ ) {
p.set(point.x, point.y);
var modelViewMatrixI= ill[j].worldModelViewMatrix.getInverse();
modelViewMatrixI.transformCoord(p);
if ( ill[j].contains(p.x, p.y) ) {
return ill[j];
}
}
}
}

p.set(point.x, point.y);
return CAAT.Scene.superclass.findActorAtPosition.call(this,p);
},

/**
* 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.
*
* @param size <number> number of lists.
*/
enableInputList : function( size ) {
this.inputList= [];
for( var i=0; i<size; i++ ) {
this.inputList.push([]);
}

return this;
},

/**
* Add an actor to a given inputList.
* @param actor <CAAT.Actor> an actor instance
* @param index <number> the inputList index to add the actor to. This value will be clamped to the number of
* available lists.
* @param position <number> the position on the selected inputList to add the actor at. This value will be
* clamped to the number of available lists.
*/
addActorToInputList : function( actor, index, position ) {
if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1;
var il= this.inputList[index];

if ( typeof position==="undefined" || position>=il.length ) {
il.push( actor );
} else if (position<=0) {
il.unshift( actor );
} else {
il.splice( position, 0, actor );
}

return this;
},

/**
* Remove all elements from an input list.
* @param index <number> the inputList index to add the actor to. This value will be clamped to the number of
* available lists so take care when emptying a non existant inputList index since you could end up emptying
* an undesired input list.
*/
emptyInputList : function( index ) {
if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1;
this.inputList[index]= [];
return this;
},

/**
* remove an actor from a given input list index.
* If no index is supplied, the actor will be removed from every input list.
* @param actor <CAAT.Actor>
* @param index <!number> an optional input list index. This value will be clamped to the number of
* available lists.
*/
removeActorFromInputList : function( actor, index ) {
if ( typeof index==="undefined" ) {
var i,j;
for( i=0; i<this.inputList.length; i++ ) {
var il= this.inputList[i];
for( j=0; j<il.length; j++ ) {
if ( il[j]==actor ) {
il.splice( j,1 );
}
}
}
return this;
}

if ( index<0 ) index=0; else if ( index>=this.inputList.length ) index= this.inputList.length-1;
var il= this.inputList[index];
for( j=0; j<il.length; j++ ) {
if ( il[j]==actor ) {
il.splice( j,1 );
}
}

return this;
}
};

Expand Down
16 changes: 16 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
02/23/2012 *0.3 Build 208*
--------------------------

* Added to CAAT.Scene the following methods:
+ findActorAtPosition(CAAT.Point) : custom actor find procedure. This is overriden to attend at the priority input lists.
+ enableInputList(number) : number of priority lists to set for this scene. A priority list is a list of actors to
which are suitable to receive input first. If no actor on the priority lists are under
the cursor, the whole scene graph is traversed instead.
+ addActorToInputList( actor, index, position ) : add an actor to a given priority list at certain position.
+ emptyInputList( index ) : remove all elements from a list.
+ removeActorFromInputList( actor, index ) : remove an actor from a list, or if no index list is supplied remove
the actor from every list in which appears.
* Fixed Actor.setImageTransformation( CAAT.SpriteImage.prototype.TR_TILE ) which didn't honor actor position and offset
to appropriately place the tiling image. Also the performance sink when using this flag with huge actors's been fixed.


02/21/2012 *0.3 Build 180*
--------------------------

Expand Down
Binary file added documentation/demos/demo-resources/img/hoppy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions documentation/demos/demo4/coordinates_org.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h1>Homogeneous coordinates</h1>
<li>Control+Drag to rotate actors.</li>
<li>Shift+Alt to unevenly scale actors.</li>
<li>Pinch, rotate and drag on iOS with native gestures.</li>
<li>Priority input lists usage.</li>
</ul>
</div>
<div>
Expand All @@ -66,6 +67,8 @@ <h1>Homogeneous coordinates</h1>
</li>
<li>TextActor optimization by caching it as bitmap.</li>
<li>Manipulating Actors zorder.</li>
<li>How to set a priority input list. In this sample the blue actor will get input prioritized
to any other rectangles and its cointained children before the blue rectangle itself.</li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -116,7 +119,9 @@ <h1>Homogeneous coordinates</h1>
CAAT.modules.initialization.init(
800, 500,
'experiment-holder',
[],
[

],
__coordinates
);
},
Expand All @@ -126,6 +131,7 @@ <h1>Homogeneous coordinates</h1>

var scene= director.createScene();


var cc= new CAAT.ActorContainer().
setBounds( 0,0,director.width,director.height );
cc.setGestureEnabled(true);
Expand Down Expand Up @@ -176,6 +182,8 @@ <h1>Homogeneous coordinates</h1>
parent.setZOrder(actor,Number.MAX_VALUE);
};

scene.enableInputList(2);

var np = 20;
var s = 80;
for ( var i = 0; i < np; i++) {
Expand All @@ -189,7 +197,7 @@ <h1>Homogeneous coordinates</h1>
s).
setRotation( Math.PI*2*Math.random() ).
setScale( sc, sc ).
setFillStyle('#ff3fff');
setFillStyle( i===0 ? '#00f' : '#ff3fff');

p.setGestureEnabled(true);

Expand Down Expand Up @@ -284,6 +292,13 @@ <h1>Homogeneous coordinates</h1>
p.mouseMove= mouseMoveHandler;
p0.mouseMove= mouseMoveHandler;
p1.mouseMove= mouseMoveHandler;

if (i===0) {
scene.addActorToInputList(p,1);
scene.addActorToInputList(p0,0);
scene.addActorToInputList(p1,0);
}

}

cc.__mouseMove= scene.mouseMove;
Expand Down
Loading

0 comments on commit 11cad28

Please sign in to comment.