instant destroy problem
CoIin
Member Posts: 197
Could you all look at this?:
http://gamesalad.com/game/play/29588
It's made with 0.6.1, so may not work unless you've updated your plugin.
Clicking on the background causes a white square to be spawned where you clicked. Clicking on the white square will destroy that square. In this case I'm using touches.
The test file shows two problems. One is that when you click to destroy a square, a new one is immediately spawned, because the background also got the click (or touch). Is there a way to have something only happen if the actor clicked on was the most forward one?
The other problem is that after clicking one square to destroy it, from then on any that you try to spawn immediately get destroyed.
In my real project I'm doing lots of attempts to solve this problem already, such as having a "dead" attribute, and also having a boolean set by a timer, so that the background won't attempt to spawn a new actor during the time that an actor is being destroyed, and an actor won't attempt to destroy itself right after being spawned. Those don't solve the problems.
So, sticking with the very simple example, how might I fix the two issues?
http://gamesalad.com/game/play/29588
It's made with 0.6.1, so may not work unless you've updated your plugin.
Clicking on the background causes a white square to be spawned where you clicked. Clicking on the white square will destroy that square. In this case I'm using touches.
The test file shows two problems. One is that when you click to destroy a square, a new one is immediately spawned, because the background also got the click (or touch). Is there a way to have something only happen if the actor clicked on was the most forward one?
The other problem is that after clicking one square to destroy it, from then on any that you try to spawn immediately get destroyed.
In my real project I'm doing lots of attempts to solve this problem already, such as having a "dead" attribute, and also having a boolean set by a timer, so that the background won't attempt to spawn a new actor during the time that an actor is being destroyed, and an actor won't attempt to destroy itself right after being spawned. Those don't solve the problems.
So, sticking with the very simple example, how might I fix the two issues?
Comments
Here's it is:
http://gamesalad.com/game/play/29672
Using touch is more likely to go wrong, but with your own example, try this:
Click to make a square, click to make it go away again. Do that as many times as you like, it should still be working (especially if you're using a trackpad).
Now click to make one, but when you click to get rid of it, do a slight drag of it first. That simulates what a touch does, and can also happen if you are using a mouse too quickly.
From then on, yours show the same problem my one does.
EDIT: Yes, it works on my computer but not online.
EDIT: o_O Now it's working fine online... I dunno what's going on. Maybe tshirtbooth will come up with something that works regularly.
Getting a lot more basic about this, is there any way to prevent a click from getting through to layers underneath? For example, if the background plays one sound and the foreground object plays a different sound, would it be possible to only hear the foreground sound when you click on that object?
If that kind of things was possible, I could use a similar trick here.