making one actor disappear and reappear by touching a 2nd actor.

jobeijobei Member Posts: 39
edited June 2012 in Working with GS (PC)
Hey everyone, I just found out how to make one actor be destroy by touching on another actor now I trying to being that actor back.
This is what Im looking for .

actor A is on the left side and actor B is on the right side. I touch actor A and that will make actor B disappear then I touch on actor A again and actor B comes back in the same spot on the right side. How do I do this?

Best Answers

  • JohnPapiomitisJohnPapiomitis Posts: 6,256
    Accepted Answer
    make a game attribute called toggleObject or whatever you want to call it.

    In actor A have when touch is pressed:
    - change attribute toggleObject to (toggleObject+1)%2

    In actor B have a rule when attribute toggleObject =1
    - change attribute self color alpha to 0

    Then in the otherwise section of that rule have a change attribute and change self color alpha to 1
  • NmdogdudeNmdogdude Posts: 174
    Accepted Answer
    create an invisible actor under actor B
    under actor A's behaviors create a rule 'when touch is pressed, spawn actor B'
  • lanmindlanmind Posts: 29
    Accepted Answer
    @jobei I believe you created your "toggleObject" attribute as a boolean type. You need to create it as an integer type.

Answers

  • jobeijobei Member Posts: 39
    make a game attribute called toggleObject or whatever you want to call it.

    In actor A have when touch is pressed:
    - change attribute toggleObject to (toggleObject+1)%2

    In actor B have a rule when attribute toggleObject =1
    - change attribute self color alpha to 0

    Then in the otherwise section of that rule have a change attribute and change self color alpha to 1
    Hey John im having some trouble on the actor B part. When I make the attribute and put "toggleObject into the box it turn the = 1sign into a true or false box.


    on my computer it say "if toggleObject is true" i know this is messing up the code

  • jobeijobei Member Posts: 39
    ohh got it thanks
  • jobeijobei Member Posts: 39
    ohh got it thanks

    Thanks it works!

  • lanmindlanmind Member Posts: 29
    @jobei you're welcome
Sign In or Register to comment.