Child Units

Nibbie
Posts: 1
Joined: 2009.09
Post: #1
I might be making up the term but what I'm trying to do is create support type units for general units and wanted to ask if anyone has suggestions.

What I mean by child unit or support unit is I have a general game unit which would be able to hold 4 support units or child units. These general game units would only be able to hold a maximum of 4 children at a given time. These children interact with the game environment independently of the main unit actions. Although they can only travel a certain distance from the main unit. Once a child is killed the main unit can generate another child.

If you have ever played an airplane shooter you would be familiar with these types of units which would be upgrades like mini plans that fly on your sides.

One issue I'm coming up with is that the user will be able to dynamically generate a number of general units which will all have their separate support units. My approach has been to create a general unit class which would then handle all the child unit creation and logic. I created an array which is populated with these support units (I have a separate class for the support units). Where I'm stuck is on rendering the units to the screen as I am not able to quickly reference the units in the array (not sure why).

Before I invest anymore time trying to get this approach to work I thought I would ask if anyone has suggestions, tips or better ideas for this problem.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #2
grazhoper Wrote:Where I'm stuck is on rendering the units to the screen as I am not able to quickly reference the units in the array (not sure why).

Sounds like you should focus on that. There shouldn't be any reason why you can't get wicked fast access to anything in an array.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  cocos2d: memory question adding child to scenes sefiroths 8 9,693 Apr 19, 2011 08:06 AM
Last Post: OneSadCookie
  how to call fathers setNeedsDisplay from child. iluzone 5 6,194 Dec 7, 2006 04:11 AM
Last Post: iluzone
  Good Game Loop with Physics Units blobbo 6 4,736 Oct 14, 2005 02:59 AM
Last Post: unknown