x


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.

more ▼

asked Jun 07 '10 at 04:50 AM

Ecnalyr gravatar image

Ecnalyr
159 13 15 26

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 instead of the first one?

Jun 21 '10 at 03:28 PM Tetrad

I was using 'destroy.'

Oct 12 '11 at 11:05 AM Ecnalyr
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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).

more ▼

answered Jun 21 '10 at 05:46 PM

BoredKoi gravatar image

BoredKoi
391 7

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1999
x764
x579
x30

asked: Jun 07 '10 at 04:50 AM

Seen: 1550 times

Last Updated: Oct 12 '11 at 11:05 AM