Closed yngndrw closed 8 years ago
me.Container
is the class that supports entity/sprite composition. You can think of it as a branch node in the scene graph; a node which can support one or many other nodes (other branch nodes, or leaf nodes).
You can build a top-down perspective tank in the way you describe. In fact, someone already did (though I cannot find the link at the moment. It was on the forum.) The hierarchy will look like this:
me.Entity
me.Body
)me.Container
)me.Sprite
or me.AnimationSheet
)me.Sprite
or me.AnimationSheet
)The body is shown for illustration that the entity is a composition of a few different classes; me.Body stores the shapes for physics interactions, and renderable (me.Container) is what the entity will use for drawing. The me.Container can draw multiple layers with arbitrary attachment points, etc.
You have to put the attachment points together by hand, since we currently don't have a great interface for describing attachments semantically. Joints might be the answer for that, or even something else entirely.
Thank you very much, that clarifies it perfectly.
Hello,
What support is there in MelonJS for entities which are made of multiple attached sprites. Examples might be entities which use Spline animation, or the turret in a top-down tower defence game, or a turret of a top-down tank ? In the tank example, you would want the body of the tank to be drawn separately from the turret, which should rotate about the body but should also move with the body.
It appears to me from reading issue #613 that the intention is for the tank to consist of the following objects: Container
When moving the tank you would move the container, when rotating the turret you would just rotate the sprite. Is this the best way of doing it or is there another suggested way ?
Thanks.