I am experimenting with Haxe and OpenFL and am wondering if the Sprite
class is synonymous with a GameObject
in Unity. It seems that sprite instances have a hierarchical structure and I am wondering if this can be utilised to manage objects.
For example:
Game (Sprite / container / no visual representation)
|--> Grid (Sprite / container / no visual representation)
|--> Tile (Sprite)
|--> Tile (Sprite)
|--> ...
|--> ...
Am I correct with the above assumption, or should the Sprite
class be extended purely for objects with visual representation?
If you only need a container, you should extend DisplayObjectContainer
. But for abstract things like Game
, I wouldn't use a DisplayObject
at all, but custom classes.
Use classes extending from DisplayObject
only for things that should be added to the Display List. In your example, Game
shouldn't be a Sprite
, but Tile
and Grid
probably yes.