Spawn/Destroy/Spawn/Destroy...

Hello the best community on the planet!!

I have one actor (button) that when is pressed he spawns 5 new actors. And now i can't figure out how to make when i press again that actore (button) to destroy those 5 spawned actors.

So basicly I want this - Button pressed spawns 5 actors, Button pressed again destroy 5 actors he spawned, Button pressed spawn 5 actors, Button pressed again destroy 5 actors he spawned ...

this is maybe important to say, button always spawns same 5 actors
and also i don't wan't my button to be destroyed just the actors he spawned.

Please help mi out guys :smiley: !

Best Answers

  • SummationSummation Posts: 476
    Accepted Answer

    @kreso123456 said:
    Hello the best community on the planet!!

    I have one actor (button) that when is pressed he spawns 5 new actors. And now i can't figure out how to make when i press again that actore (button) to destroy those 5 spawned actors.

    So basicly I want this - Button pressed spawns 5 actors, Button pressed again destroy 5 actors he spawned, Button pressed spawn 5 actors, Button pressed again destroy 5 actors he spawned ...

    this is maybe important to say, button always spawns same 5 actors
    and also i don't wan't my button to be destroyed just the actors he spawned.

    Please help mi out guys :smiley: !

    You could make the spawned actors' existence contingent upon a game level attribute like 5alive.
    In the spawned actors make a rule that says if 5alive=1, destroy actor.
    You can keep the spawning behavior in your button, but add a toggle in your touch behavior that switches back and forth between 1 and 0.
    This way you can touch, they spawn, touch again, they die, etc.

  • MentalDonkeyGamesMentalDonkeyGames Posts: 1,276
    Accepted Answer

    Is this even close to what you´re looking to achieve @kreso123456 ?

    Made with Mac creator 0.13.7

    Mental Donkey Games
    Website - Facebook - Twitter

Answers

  • JimmyMesserJimmyMesser LondonMember Posts: 235

    Can you do that using an integer?

    On press change attribute to +1

    Then spawn when the integer is = 1

    And destroy when it's = 2

    Maybe run a timer that resets it after 2 seconds

    Might be an better way but thats all I can come up with.

  • kreso123456kreso123456 Member Posts: 16
    edited May 2015

    @Summation

    but add a toggle in your touch behavior that switches back and forth between 1 and 0

    Could you just tell me how to do that?

    I am kinda new to gamesalad :smiley:

  • SummationSummation Member, PRO Posts: 476

    @kreso123456 said:
    Could you just tell me how to do that?
    I am kinda new to gamesalad :smiley:

    Probably the simplest way is to make use of a boolean.

  • kreso123456kreso123456 Member Posts: 16

    @Summation

    I seem to have a little problem here.

    • So i made game integer and named him 5alive
    • In spawned actores i made Rule - Attribute game.5alive = 1, Destroy actor
    • In my button i made boolean and named him kill... aaand this is where i am stuck

    i should have told this earlier but i am total noob :smiley:

    And i really need you to tell me step by step on what to do next :smiley:

    sorry but I am really, really new to gamesalad and only at the beginig of the learning phase. I WOULD APRECIATE YOUR TIME AND HELP ALOT! :blush:

  • kreso123456kreso123456 Member Posts: 16

    @NipaDidIt AWESOME!!! thank you!!!

    I just change it a bit because i need my actores to spawn at the right XandY and not randomly but that is it!! THANK YOU VERY MUCH you are awesome! :smiley: :smiley:

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    No problem, glad i could help :smile:

    Mental Donkey Games
    Website - Facebook - Twitter

Sign In or Register to comment.