Change image on touch --> touch again and change image to original

kreso123456kreso123456 Member Posts: 16
edited March 2015 in Working with GS (PC)

Hi all!

Please help me!

I have one actor and I want him to change image on touch. I have 2 images (one is white, second is yelow)
Original image is white and when touched it changes to yelow image.

And now i want to touch again to change it back to original white image.
How to do that??

Thanks!

Best Answers

  • jonmulcahyjonmulcahy Posts: 10,408
    Accepted Answer

    what I would do (which may or may not be the best way) is to have a toggle switch. create a local attribute on the actor called toggle

    when touch is pressed
    change self.toggle to mod(toggle+1,2)

    with this rule, as you touch the actor it will increment the toggle attribute to 0,1,0,1,0,1.

    so have another rule that says

    when self.toggle is 0
    change image to white
    otherwise
    change image to yellow

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

    @kreso123456 said:
    I figured it out! Thank you very much!

    You could just name your images 0 and 1.

    Then use:

    when touch is pressed change self.image to 1-self.image.

Answers

  • kreso123456kreso123456 Member Posts: 16
    edited March 2015

    I am kinda new to the gamesalad, so if you could be more detailed.

    "create a local attribute on the actor" - how to create local atribute?

    Thank you on yore time!! :smiley:

  • kreso123456kreso123456 Member Posts: 16

    do i need to create integer or boolean or what?

  • kreso123456kreso123456 Member Posts: 16

    I figured it out! Thank you very much!

Sign In or Register to comment.