How to destroy the top enemy of a pile by clicking on it?

carecuxocarecuxo Member Posts: 6
edited November 2013 in Working with GS (Mac)
Hello guys, I am new to Gamesalad, and I am using this project to learn how to work with the program.

In this game, you must click on the zombies before they reach Einstein. There are also 2 different weapons to be chosen (I'll put a cooldown later).

My problem is: there are lots of zombies spawning on both sides of the screen, and the spawn rate grows when the player scores. Sometimes, one or more zombise stay in front of another ones, making like a "pile" of zombies. When I click to kill, they ALL get killed instead of just the one that is on the top.

How can I make the game kill only the top zombie?

Game link: http://arcade.gamesalad.com/g/116376

Thanks in advance for your help.

Comments

  • myke66myke66 Member Posts: 74
    Ive ran into this issue before, Im not sure if the gamesalad engine can distinguish the different "layers" of touch collision when actors overlap. Hopefully someone more knowledgeable than myself can answer.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
  • carecuxocarecuxo Member Posts: 6
    Thank you very much for your answers.

    I searched on the link, also on youtube videos and some other internet tutorials, but I couldn`t make any one of them to work. When I click to kill overlapping zombies, they all get destroyed at the same time. I wasn`t able to solve this.

    Do anyone have any suggestion?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @carecuxo did you actually try this? Because I believe that's the best way to achieve what you're trying to do.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I followed the link in my post above and made a demo. It's very tricky stuff and the demo works to destroy the most recently spawned (highest ID) actor but only if I spawn new actors to the back of the layer, which then makes them appear to be earlier/under the older actors.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • carecuxocarecuxo Member Posts: 6
    I tried with your demo, even modifying the game for testing purposes (just one zombie and only one spawner) and a new issue appeared. When I touch and hold the screen, all zombies are destroyed, instead of just one. =S

    Here is my file again

    https://www.dropbox.com/s/ki4oq872lyahh7k/prototypetest.zip
  • carecuxocarecuxo Member Posts: 6
    On a second try, I just can`t damage my enemies. I just want to find out what I am doing wrong =(


    https://www.dropbox.com/s/mhiwcqnhi7b9fn2/prototypetry2.zip
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    The first problem sounds like you used When Mouse Button is Down instead of When Touch is Pressed. I'll take a look at the second file...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you compare your rules to my demo, you'll see that you changed the After 0.1 seconds timer that resets game.highestIDtouched to 0 to an every 0.3 seconds timer and changed the order of the behaviors slightly. Go back to my demo and make your zombie rules look like that. I just reverted it for one zombie and it worked.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • carecuxocarecuxo Member Posts: 6
    I revised everything (And changed some stuff according to my game design) and still got problems.

    The changes worked when there is just only one zombie on the screen. When I start to spawn zombies 2, 3 and 4, the things go wrong.

    The first time, I got a delay on click+damage+destroy. There was a delay of 0.5 to 1 second before the zombie got destroyed.

    Then, with more zombies on the screen, I was able to just kill some of the zombies, and just the ones that were on the botton layer.

    https://www.dropbox.com/s/il902qqs12ehvwg/prototypetry3.zip
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I believe you're trying to do something that no one has done before so the fact that it's challenging is a given. (Someone please correct me if I'm wrong.)

    I'll take a look when I get a chance later.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Here is a way to do relative z-order layering. It takes advantage of the fact that actors are evaluated from the bottom layer up, and that behaviors fire from the top down.

    http://www.mediafire.com/download/ktne3dd9afrd9b8/DestroyTopActor.zip
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @RThurman amazing! Now I just have to go figure out how it works. ;)

    I added a spawner with Layer Order set to front of layer and it works beautifully.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @Tatiang -- It is amazing what GameSalad can do! And often with just a few simple behaviors. But since it is so simple to use, we are often limited by our own misperceptions of what GameSalad is capable of.

    I think its funny when people get frustrated about how they need to make 'workarounds' to get GameSalad to do what they want. In reality, GameSalad's extreme flexibility is its greatest strength. (Not that anyone is complaining in this thread. I just meant in general.)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Tatiang -- It is amazing what GameSalad can do! And often with just a few simple behaviors. But since it is so simple to use, we are often limited by our own misperceptions of what GameSalad is capable of.
    Absolutely! Anyone who spent a few minutes looking through the Spare Code thread would be blown away by what people have managed with GameSalad. It really is limitless in a lot of ways (and yes, limited in some important ways as well).

    Just seeing that joints video blew my mind, for example.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited November 2013
    @tatiang -- That reminds me that I could probably post the above demo to the spare code thread. Think its worthy?

    If you liked the joints video then you will hopefully like the little Christmas gift I have prepared for the GameSalad community! If you want it, I can pm you a copy of an early prototype.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @tatiang -- That reminds me that I could probably post the above demo to the spare code thread. Think its worthy?

    If you liked the joints video then you will hopefully like the little Christmas gift I have prepared for the GameSalad community! If you want it, I can pm you a copy of an early prototype.
    @RThurman Yes and yes, please.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    I think I accidentally hijacked a thread!

    @carecuxo -- hopefully the demo above will give you a feel for what to do. Feedback on whether it works for you is always appreciated.
Sign In or Register to comment.