Skip to content

Commit

Permalink
Fixed setLocation on BodyActor so that it sets x and y properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne Brutschy committed Feb 3, 2013
1 parent 174b59c commit 3f7227f
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions src/Foundation/Box2D/B2DBodyActor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ CAAT.Module({
return this;
},

setPositionAnchor : function( ax, ay ) {
this.tAnchorX= .5;
this.tAnchorY= .5;
},

setPositionAnchored : function(x,y,ax,ay) {
this.x= x;
this.y= y;
this.tAnchorX= .5;
this.tAnchorY= .5;
},

/**
* set this actor to recycle its body, that is, do not destroy it.
*/
Expand Down Expand Up @@ -128,13 +116,46 @@ CAAT.Module({
this.worldBody.SetSleepingAllowed(bool);
return this;
},
/**
* This method sets the position of an Actor inside its parent.
*
* @param x{number} a float indicating Actor's x position
* @param y{number} a float indicating Actor's y position
* @return this
*
* @deprecated
*/
setLocation:function (x, y) {
this.x = x;
this.y = y;
this.oldX = x;
this.oldY = y;

this.dirty = true;
this.worldBody.SetPosition(
new Box2D.Common.Math.b2Vec2(
x / CAAT.PMR,
y / CAAT.PMR));
return this;
},

setPosition:function (x, y) {
return this.setLocation(x, y);
},

setPositionAnchor:function (pax, pay) {
this.tAnchorX = pax;
this.tAnchorY = pay;
return this;
},

setPositionAnchored:function (x, y, pax, pay) {
this.setLocation(x, y);
this.tAnchorX = pax;
this.tAnchorY = pay;
return this;
},

/**
* Set this body's
* density.
Expand Down

0 comments on commit 3f7227f

Please sign in to comment.