How to Tween the position of Sprite inside SpriteGroup?
-
So I want tween a sprite so it moves up 100 px from where it was:
FlxTween.tween(card, {x: card.x, y: card.y + 100}, 0.1)
But
card
is inside anFlxSpriteGroup
. So when I access the x and y, it is local coordinates. But the tween moves the card to absolute coordinates. How can I achieve my expected behavior? This could be solved easily if I could get a sprite's absolute coordinates when its inside a sprite group.EDIT: Well, I think I solved it as long as you are calling code inside the FlxSpriteGroup you're working in. You can get the group's global position with
this.getPosition()
, even if that group is also in another group. Then you can add that to your sprite's local position to get its global position.