Dynamic class change?
Dynamic class change?
- Subject: Dynamic class change?
- From: Justin Bakse <email@hidden>
- Date: Wed, 1 Jun 2005 11:28:49 -0500
I am looking for general thoughts on how to make an object change its
class during runtime. Or at least make it appear to. The objects
would be chaning between related classes, probably all subclasses of
the same parent. To make it clearer what I'm trying to do, and why,
here is a little context. These objects will represent enemies in a
game level editor. The editor is built in the full running engine of
the game, with time stopped. When you place the a new enemy on the
level, an object of some enemy subclass is generated, and it draws
itself, and otherwise behaves just as it would during game play
(except paused). Later, you might wish to change the class of the
enemy. That is when I wish have the object change class.
My thinking right now is that the object (or some where else in code)
would have to create a new object, copy over all the member data that
it could, and then delete the original. One possible problem of that
is that any other objects that reference the changing object would
have to be updated to reference the new object.
Anyone have any ideas for a better way to get this effect?
-Justin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden