I have a class GameObject.
I wanted subclasses of this:
PlayerObject
EnemyObject
EmitterObject
ShotObject
But instead I'm just using GameObject and setting an "objectType"
integer based on what type of object it is supposed to be.
Then, when the GameObject has its nextFrame or collision methods
called, it uses a Select Case to see what its objectType is, and
performs accordingly.
This seems silly. I think I'm missing something about how classes work.
I understand inheritance at the simplest level, and I don't see how I
can simplify this.
I tried a sample project to see if I could just have an array that
holds GameObjects, and I could append whatever subclass of GameObject
to it I wanted (i.e append a PlayerObject, then append a few
EnemyObjects, whatever...). Then I could just say myArray(i).nextframe
and it would do the nextframe for the appropriate subclass. (i.e. if
myArray(i) had been added as an EnemyObject, it would execute the
nextframe method as written in the EnemyObject subclass.)
Well, that doesn't work (I didn't see how it could, but thought I'd
try).
Is this that situation where I might be able to do it, but I'd have to
typecast all the time?
Sorry, it's late.
Paul
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|