I've been creating all my world objects by sub-classing Layer. Each layer would have a primarySprite which gets set up in the init method. This class also holds variables like health points, shield points, etc. Is this the a decent pattern to use? Using a separate layer for each enemy and the hero seems inefficient, would sub-classing the Sprite class be better?
game objects, better to use Sprite or Layer?
(2 posts) (2 voices)-
Posted 2 years ago #
-
I use cocosnode to subclass because layer and sprites both inherit this. If I need to add sprites for drawing I can add them to self like normal as well as retain the ability to add my cocosnode object to a layer as if it was a sprite. This allows me to keep a good zorder for my objects drawing.
Posted 2 years ago #
Reply
You must log in to post.