How to change image through a swipe
xojessykah
Member Posts: 2
I have created an actor that the user is able to swipe, and when swiped, an image pops up... the image only changes once, and when swiped again, nothing happens. How do I make it so that each time the user swipes it, a different image pops up, replacing the existing image? Thanks!
Comments
First off find out how many images you want to cycle threw. Ill use 5 as an example.
Next have a attribute called selectedImage
Now when you have a swipe happen, change attribute selectedImage to (selectedImage+1)%5
that will cycle between 0,1,2,3, and 4 when a swipe takes place
then have rules when selectedImage=0 change image to image1
when selectedImage=1, change image to image 2 and so on
cheers
Is there any way to simplify it for me please?
Make an attribute . . . (let's call it NEWIMAGE)
Every time the user swipes - increase this attribute by 1.
Then add (for example) 5 rules to your actor.
If NEWIMAGE is 1 then change the image to image 1
If NEWIMAGE is 2 then change the image to image 2
If NEWIMAGE is 3 then change the image to image 3
If NEWIMAGE is 4 then change the image to image 4
If NEWIMAGE is 5 then change the image to image 5
You also need to tell the actor that there are only (for example) 5 different images to cycle through so it doesn't keep adding 1 to the value of the attribute and go past 5 (because in your rules (above) there are no images that correspond to 6 7 8 9 etc) - instead we want the attribute to go 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 . . . rather than 1 2 3 4 5 6 7 8 9 . . .
This is done by when you increase the attribute every time it is swiped . . . . . like this:
Change attribute • game.NEWIMAGE • to • (NEWIMAGE+1)%5
The percentage sign and the 5 tells GS how many images there are to cycle through.
http://img825.imageshack.us/img825/3553/10908143.jpg
(I've only put three rules (and images) in, but imagine there are 5).