• 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: Glen Simmons <email@hidden>
  • Date: Wed, 1 Jun 2005 11:39:45 -0500

You could have an object that contains the enemy object. The containing object would never change or get deleted, but when told to, would change out the enemy object it contains. To the outside world, it could appear to *be* the enemy object, along the lines of what NSProxy does, pretending to be another object by forwarding messages to the real object.

HTH,
Glen

On Jun 1, 2005, at 11:28 AM, 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.

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:
40gmail.com


This email sent to email@hidden


_______________________________________________ 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: Re: Coredata schema question.
  • Next by Date: Re: Dynamic class change?
  • Previous by thread: Dynamic class change?
  • Next by thread: Re: Dynamic class change?
  • Index(es):
    • Date
    • Thread