No, I don't want a squad of tanks to act as a group, but several tanks to act as individual units.
by making several instances, did you mean in an array like this:
| int tanksCount = -1 |
| int oldTanksCount |
| protected override void Update(GameTime gameTime) |
| { |
| if(Keyboard.GetState().IsKeyDown(Keys.Space)) |
| { |
| tanksCount++ |
| } |
| |
| if(oldTanksCount != tanksCount) |
| { |
| Tanks[tanksCount] = new TanksControl |
| } |
| |
| if(tanksCount => 0) |
| { |
| for (i = 0; i < tanksCount; i++) |
| { |
| Tanks[i].Update(); |
| } |
| } |
| oldTanksCount = tankCount; |
| base.Update(gameTime); |
| } |
I'm not near a computer with XNA right now, so I'll won't be able to test it, but I hope you can give me feedback on the code above.
Edit: I tried this, but it seems like I need 'Indexes' to make classes work like arrays. I read about it in the help file, but still isn't quite sure on how to use it in my programm. I would have exprimented on it, but i'll have to go to school, so I hoped anyone knew something about this. It would save me alot of time :)
Again, Thanks