• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dynamic class change?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic class change?


  • Subject: Re: Dynamic class change?
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 1 Jun 2005 17:01:25 -0400

On Jun 1, 2005, at 12:28 PM, Justin Bakse wrote:

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.

Sounds reasonable to me.

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.

You could keep all of your game objects in a dictionary or array. When other objects need to refer to an object, they could do so by using the dictionary key or array index, instead of doing so directly.


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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


References: 
 >Dynamic class change? (From: Justin Bakse <email@hidden>)

  • Prev by Date: test please ignore
  • Next by Date: Re: two NSArrayControllers
  • Previous by thread: Re: Dynamic class change?
  • Next by thread: Re: Coredata schema question.
  • Index(es):
    • Date
    • Thread