Reputation: 21
I'm basically trying to emulate what you see in many other frameworks like Flash, XNA, etc. If I create a hierarchy of nested entities on stage, how do I rotate, scale, or translate a parent entity and have its children rotate, scale, and translate relative to the parent's origin point?
Upvotes: 1
Views: 380
Reputation: 10143
Lets say you have this setup:
Entity (called enemy)
> Sprite
-- Entity (called leg)
> ImageSprite
-- Entity (called arm)
> ImageSprite
-- Entity
> ImageSprite
If you want to rotate the enemy, you should do enemy.get(Sprite).rotation._ = 35; Then the whole character should rotate.
If you want to rotate a part of it, use leg.get(Sprite).rotation.animateTo(35, 0.5, Ease.sineOut);
You can nest entities using addChild, and components (like Sprite) using add(). The displaylist is build using entities that contain Sprites, but not plain nested Sprites like Flash.
I suggest you could take a look at my Flambe guide, some basic concepts (that can be confusing at start) are explained in it https://github.com/markknol/flambe-guide/wiki/
Have fun, please let know if you have questions.
Upvotes: 0