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?
            Asked
            
        
        
            Active
            
        
            Viewed 373 times
        
    1 Answers
0
            
            
        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.
        Mark Knol
        
- 9,663
 - 3
 - 29
 - 44