Problem with logic - (I think)

Has anyone got any ideas why line 55 only takes place when the 2nd enemy( a cube at the moment) is created and not the first self destruct - Pastebin.com

The idea is if a cube has self destructed and was not ‘captured’ by the player the game will end.

But if I dont save the first cube the game continues anyway, but every cube after that seems to set gameEnd ==true if a cube has been destroyed as it should.

Not sure what you mean here. To me, it looks as though the “remaining” variable is keeping track of the remaining time and calls EnemyDestroy when there is only one minute left. It doesn’t seem to have anything to do with the state of the enemy objects. Perhaps you can explain what is happening a little further?

Sorry about being unclear.

Each enemy objet destroys itself after 4 seconds (unless the user is able to stop). So if remaining = 1 the enemy will destroy itself.

The user needs to catch it ( when they do this the enemy is still destroyed but points are added to the score and the game continues.

The problem is that there is a ‘rogue’ cube which is the first one created, unlike every other cube created after it if the time runs out (remaining == 1) instead of ending the game it creates another cube and the game continues. This is the only cube that does this and every other cube created behaves in the correct way.

Please let me know if this is still unclear as I really want to get the problem solved.

Thanks

There doesn’t seem to be anything in the code you’ve posted that could create a new object. Can you post the code where the cube is added to the scene? Is the same code used for the first cube? (I’m thinking maybe the difference could be that you have the first cube already in the scene and the rest are instantiated or something?)

Sorry I meant to also post that.

Here is the code I use for creating each cube: http://pastebin.com/8QZMXw1F

Thanks again for your help, I really appreciate it.