Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
GTween + Box2D - keeping position in sync? [SOLVED] — Gideros Forum

GTween + Box2D - keeping position in sync? [SOLVED]

hotbutteredhotbuttered Member
edited June 2016 in General questions
I'd like to add back and forth movement to a Sprite that has a corresponding Box2D (static) physical body. I've tried using GTween for this, without success.

The problem seems to be that sprite:getPosition() while a GTween is running returns the original position of the sprite, instead of its updated position due to the tweening. Thus the code that updates the position of the Box2D physical body never moves the body to keep up with the tween.

Is it possible to overcome this? If not, any suggestions for an alternate approach? I thought to try using a Box2D impulse to move the body back and forth, but I'm not sure how that will work given that the body is static.

EDIT: Instead of using GTween, it looks like I can use Body:setPosition to move the physical body back and forth inside onEnterFrame(). Then the existing code that I'm using to keep sprites in sync with their physical objects should work as is.

Comments

Sign In or Register to comment.