Clicking top actor only when overlapping another actor.
Hi guys (and girls). I have been trying to solve this issue for an hour or 2 with no success. (-_-) I've searched the forum but can't find a specific solution.
Basically I have a 'shooting gallery' style game where you click/tap an actor to destroy it. If it's a 'bad guy' you also get points. If you tap a 'good guy' you lose a life. The actors spawn in random positions meaning occasionally they overlap. I'd like to make it that if you click the top actor they will disappear (and you'll get points or lose life) WITHOUT registering a hit on the actor behind. At the moment both actors disappear.
I have tried creating an index attribute and assigning actor numbers to each actor but can't seem to get it to work. I also tried an 'otherwise' rule for when actor is not overlapping another. I must be doing something wrong! Any help would be much appreciated. Please be as detailed as possible as I am new to GS.
Basically I have a 'shooting gallery' style game where you click/tap an actor to destroy it. If it's a 'bad guy' you also get points. If you tap a 'good guy' you lose a life. The actors spawn in random positions meaning occasionally they overlap. I'd like to make it that if you click the top actor they will disappear (and you'll get points or lose life) WITHOUT registering a hit on the actor behind. At the moment both actors disappear.
I have tried creating an index attribute and assigning actor numbers to each actor but can't seem to get it to work. I also tried an 'otherwise' rule for when actor is not overlapping another. I must be doing something wrong! Any help would be much appreciated. Please be as detailed as possible as I am new to GS.
Comments
Try this - make a boolean attribute (one that is on, off) in the "game" section, when you click on the baddy actor, it changes that attribute to false. And quickly after that, (using an "after" (of about 0.1 seconds) timer on "run to completion") set that attribute back to true.
NOW - on the goody actor, set that it can only be "shot" if the attribute is true. That way there is a tiny gap where the goody is not hurt while the baddy one is being "shot".
Hope this isn't too confusing, just reply and ask if i need to slow down for extra slow-mo help.
I think this is what you mean.
you can download the project file by searching for it in the GameSalad creator
Bad guy:
http://i140.photobucket.com/albums/r5/mantastic001/Screenshot2011-07-10at125210AM.png
Good guy:
http://i140.photobucket.com/albums/r5/mantastic001/Screenshot2011-07-10at125231AM.png
My problem was that the bad guy actor was controlling the boolean attribute (to true), but the same actor was being destroyed instantly when clicked before it had a chance to perform the switch back to false. So instead of destroying the actor instantly I made it disappear (alpha = 0) when clicked, then changed the boolean attribute to true > false for a split second, THEN destroyed the invisible actor a split second later. Working fine now.
Thanks so much for the help!