How to destroy an actor like this.

TailGamesTailGames Member Posts: 76
edited May 2012 in Working with GS (Mac)
i have a button and a electrical current that i want to turn off with the button,when the button is pressed the electricity stops, how can this be acheived?

if you have anyway of making a video demonstrating that would be amazing!!!!

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Create a game level boolean attribute (attribute tab above the actor list when you are in a scene). Call it something like game.ElecOn and then check the box next to it so that its default setting is true

    Then in your button you have a simple rule like this:

    Rule: when touch is pressed change attribute game.ElecOn to false

    Then in any rule that depends on the electricity being on you just wrap it in a rule that says when electricity it false.

    Example:

    In the electricity actor:

    When game.ElecOn is true
    change self.color.alpha to 1
    animate .....
    OTHERWISE
    change self.color.alpha to 0

    In your hero that doesn't want to get electricuted:

    When game.ElecOn is true AND
    when actor overlaps with actor of type elctricity
    change self.Dead to true (you would have to create this self attribute of course)

    When self.dead is true
    animate (death sequence)
    Timer: after 2 seconds
    reset scene
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Create a game level boolean attribute (attribute tab above the actor list when you are in a scene). Call it something like game.ElecOn and then check the box next to it so that its default setting is true

    Then in your button you have a simple rule like this:

    Rule: when touch is pressed change attribute game.ElecOn to false

    Then in any rule that depends on the electricity being on you just wrap it in a rule that says when electricity it false.

    Example:

    In the electricity actor:

    When game.ElecOn is true
    change self.color.alpha to 1
    animate .....
    OTHERWISE
    change self.color.alpha to 0

    In your hero that doesn't want to get electricuted:

    When game.ElecOn is true AND
    when actor overlaps with actor of type elctricity
    change self.Dead to true (you would have to create this self attribute of course)

    When self.dead is true
    animate (death sequence)
    Timer: after 2 seconds
    reset scene
    By wrapping the overlap with electricty actor in the when game.ElecOn is false rule your hero can overlap with the invisible (i.e. off) electricity actor and nothing happens. But when game.ElecOn is true you will see your iamge (or animation) and if the hero overlaps with it he will get fried.

  • TailGamesTailGames Member Posts: 76
    im new to gamesalad rules and i don;'t know what the true and false things are....
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    If you don't know what rules are in gamesalad then you really need to start by doing a little homework:

    1) Open up some of the demo projects found in the GScreator start window
    2) Go to youtube and look at the GameSalad CookBook channel.
    3) Go to GShelper.com and watch TshirtBooth's videos

    After you have done that my explanation above will be very easy to understand.

    Best of luck!
Sign In or Register to comment.