Cycle through question...

DrGlickertDrGlickert Member Posts: 1,135
edited November -1 in Working with GS (Mac)
Is this correct? I can't remember.

I have 4 images. I want the player to tap on the image to go to the 2nd image, tap again they go to the 3rd image and then 4th image.

So....

When touch is pressed: Change Attribute Which Image to (Which Image+1)%4

THen a rule that corresponds the Which Image number to the correct picture. But that's right, right?

Comments

  • MattGibbardMattGibbard Member Posts: 45
    You could do this within the same actor to save yourself space. Create a variable in that actor called "ImageNo" and it to 1. Then upon touch press, change variable ImageNo=ImageNo+1 (What you said).

    Then create some rules:
    If ImageNo=1
    Change Image...
    If ImageNo=2
    Change Image...
    ect

    You will need to use the Change Image behaviour.

    Hope this helps.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    DrGlickert said:
    Is this correct? I can't remember.

    I have 4 images. I want the player to tap on the image to go to the 2nd image, tap again they go to the 3rd image and then 4th image.

    So....

    When touch is pressed: Change Attribute Which Image to (Which Image+1)%4

    THen a rule that corresponds the Which Image number to the correct picture. But that's right, right?

    Yep thats correct and probably the most eficient way. Go with that.
  • Rob2Rob2 Member Posts: 2,402
    Don't forget you can use something like

    change attribute self.image to "pic"..self.whichImage..".png"

    to do the actual image switching
  • MattGibbardMattGibbard Member Posts: 45
    Rob2 said:
    Don't forget you can use something like

    change attribute self.image to "pic"..self.whichImage..".png"

    to do the actual image switching

    I learn something new everyday!
Sign In or Register to comment.