From 8a88fa6e0c7cd8cfc43d6a0f7e0c47620d78a7fb Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sun, 3 Feb 2013 14:41:40 +0100 Subject: [PATCH 1/2] Fixed setLocation on BodyActor so that it sets x and y properly --- src/Foundation/Box2D/B2DBodyActor.js | 45 ++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Foundation/Box2D/B2DBodyActor.js b/src/Foundation/Box2D/B2DBodyActor.js index f941fe12..fffcbb44 100644 --- a/src/Foundation/Box2D/B2DBodyActor.js +++ b/src/Foundation/Box2D/B2DBodyActor.js @@ -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. */ @@ -173,13 +161,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. From e6b422421c369f8c71a2a6abf8a1c0a658ea94f7 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sun, 3 Feb 2013 16:43:22 +0100 Subject: [PATCH 2/2] Forgot to cleanup Conflicts: src/Foundation/Box2D/B2DBodyActor.js --- src/Foundation/Box2D/B2DBodyActor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Foundation/Box2D/B2DBodyActor.js b/src/Foundation/Box2D/B2DBodyActor.js index fffcbb44..8d131750 100644 --- a/src/Foundation/Box2D/B2DBodyActor.js +++ b/src/Foundation/Box2D/B2DBodyActor.js @@ -181,6 +181,7 @@ CAAT.Module({ new Box2D.Common.Math.b2Vec2( x / CAAT.PMR, y / CAAT.PMR)); + return this; },