- Home /
I want to destroy the top object from a stack of objects on touch, not all objects.
I have an iPhone game that involves destroying objects by touching them.
When I touch an collidable object, it is destroyed.
However, if these objects are stacked (I have many such objects being spawned at once), it destroys all of the objects that are on the spot that one touches.
All objects are moving around in x,y space, they all have a z of zero (it is a 2d game).
How do I make the game only destroy the topmost item (they have a z of zero, but objects look as if they are on top of one another) instead of destroying all of the objects when I touch a spot?
If it matters, I am using the FingerManager from the forums to dictate my 'touch' action.
Going to be hard to help you without knowing how you're deleting your objects in the first place. Blind guess: are you deleting objects every frame your finger is down ins$$anonymous$$d of the first one?
Answer by BoredKoi · Jun 21, 2010 at 05:46 PM
Sounds like you need to destroy the touched object and then set a bool flag that will not allow any further touch destruction(s) until TouchPhase.Ended is reached (i.e. finger lifted).
Your answer
Follow this Question
Related Questions
Can't seem to destroy instantiated objects. 1 Answer
All objects response to one touch 1 Answer
Touches don't respond correct 2 Answers
Destroy on touch for iphone 1 Answer