Actors with multiple Textures

Hi all!

This is a shameless re-post of my Stack Exchange Game Development question of the same name.

In my 2D side-scroller game I have a bunch of actors being drawn, each of which has a single, non-animated Texture (a png image). These actors all inherit from a base GameActor class.

I want to add some more NPC’s (e.g. tanks or cannons) that have one texture that doesn’t move (the base) and another that rotates to shoot at things (the gun / barrel). How should I structure my Actor class hierarchy so as to allow for this? Should I refactor my base Actor class to allow for N textures? Or should I create a brand new sort of Actor for things that need > 1 texture (and then have to manage these actors separately from ‘regular’ actors)? Or is there a better approach I can’t see?

Thus far I’ve been opting to keep things as simple as possible (KISS, right?), but am not sure how to proceed.

Any pointers greatly appreciated.

Comments

24. Jan 2013 · 11:46 UTC
Why not make a ‘actors-group-with-position’?
deathray
25. Jan 2013 · 00:52 UTC
If you allow for N-textures, then your actor class becomes very versatile. Is there a downside? What are the pros and cons? And what language are you using?
28. Jan 2013 · 22:01 UTC
Posted a reply to your post on StackExchange. Basically I would be careful of making your Actor class too complicated, you’ll regret it down the road. I would suggest adding some kind of parenting or constraint system and represent the tank as two Actors that are parented or constrained together.