How to make actor spawn only once?

justinodunnjustinodunn Member, PRO Posts: 226
i made it so if the user touches the screen an actor will spawn and appear for a few seconds and be destroyed when the timer is up. But when i touch the screen again, the actor will spawn again... so how can i make it spawn only once after the screen is touched once?

Comments

  • ArmellineArmelline Member, PRO Posts: 5,369
    There are a number of ways of doing this. Which is best will really depend on how you're handling the touch of the screen. Probably the easiest and safest way though is to have an attribute (boolean or integer) that you toggle when the actor is spawned.

    Rule: When attribute TOGGLE is 0 then
    Spawn Actor
    Change attribute TOGGLE to 1

    That way, it'll only spawn the actor when TOGGLE is 0, and as soon as the actor is spawned, it'll change toggle to 1, preventing any further spawning.
  • SocksSocks London, UK.Member Posts: 12,822
    Make boolean attribute.

    Touch changes it to true.

    When true spawn actor.
  • ArmellineArmelline Member, PRO Posts: 5,369
    I think this thread may demonstrate that Socks is an optimist and I'm a pessimist.
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    I think this thread may demonstrate that Socks is an optimist and I'm a pessimist.
    :) :-/ ;) ?
  • justinodunnjustinodunn Member, PRO Posts: 226
    edited February 2014
    Nevermind, got it! Thank you guys! It's good to sometimes be pessimistic and sometimes optimistic ;)
  • ArmellineArmelline Member, PRO Posts: 5,369
    edited February 2014

    :) :-/ ;) ?
    We came up with essentially the same solution at the same time, but yours relied on something being true and mine relied on something being false :P
  • SocksSocks London, UK.Member Posts: 12,822

    :) :-/ ;) ?
    We came up with essentially the same solution at the same time, but yours relied on something being true and mine relied on something being false :P
    :)
  • RedCubeGamesRedCubeGames Member Posts: 37
    edited May 2015

    @justinodunn Can you please share with me how you did it? I am killing my self over here trying to make it work but nothing. I tried @Socks and @Armelline methods but it seems i am making mistake somewhere but i don't know where!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @RedCubeGames You might want to post a screenshot of your rules so we can help you (upload the screenshot to a file-sharing site and then embed/post the link here). Based on what @Armelline wrote, the rule should be:

    When Mouse Button is Down
         When Attribute self.toggle (integer or boolean) is 0
              Spawn Actor [actor name]
              Change Attribute self.toggle to 1

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

  • RedCubeGamesRedCubeGames Member Posts: 37

    @tatiang said:
    RedCubeGames You might want to post a screenshot of your rules so we can help you (upload the screenshot to a file-sharing site and then embed/post the link here). Based on what Armelline wrote, the rule should be:

    When Mouse Button is Down
         When Attribute self.toggle (integer or boolean) is 0
              Spawn Actor [actor name]
              Change Attribute self.toggle to 1

    You are the best @tatiang ! It is working now! ;))) THANK YOU VERY VERY MUCH!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're welcome!

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

Sign In or Register to comment.