ID:261845
 
For my game, I'd like to know how to make it so that when a user clicks on lets say an arrow, the user's icon changes to another icon, it does this every time the user clicks the arrow.
Example: The user's icon startsout as a small ball, when the arrow is clicked first time, the ball gets bigger, clicked again, the ball gets bigger, one again this happens, the ball gets bigger, this occurs for a total of 5 times. I have a code of what my idea was, but it doesnt work. The problem is that it changes the icon each time, but in the end if you click it again it goes down once to make the icon smaller. I know why theres the problem, but I don't know what to replace the if with to fix it. Well, here it is...
P.S: I have the CD variable defined elsewhere, im sure its not needed.....


turf
ArrowRight
Click()
if(usr.CD == 0)
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW2"
usr.CD +=1
else
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW4"
if(usr.CD == 3)
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW5"
turf
ArrowRight
Click()
switch(usr.CD)
if(0)
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW2"
if(1)
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW4"
if(2)
usr.icon = 'Slime.dmi'
usr.icon_state = "SlimeW5"
usr.CD += 1
if(usr.CD > 2)
usr.CD = 0

I think this should work for your purposes. All you need is more if()s for each different icon and iconstate that you want. You'll also need to change the bottom if() to be the last number you did an if() check for. Also, usr.icon doesn't need to be set everytime if every icon_state you're using is in the same icon file.
In response to Jon88
Oce again Jon saves the day, thanks a million.