Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Fix set location body actor #162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions src/Foundation/Box2D/B2DBodyActor.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,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 @@ -173,13 +161,47 @@ 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