How do I toggle more than two states?

Get help using Construct 2

Post » Tue Jun 10, 2014 12:38 pm

I'm trying to create a button that will toggle between three states (default=state1, clicked once=state2, clicked twice=state3 and if clicked again, back to state1).

This is easy if you only have two states, using Else, but I would appreciate a hint about how I can achieve this with more states.
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Tue Jun 10, 2014 1:11 pm

Just add an instance variable example "clicked"
if on touch with button (mouse click) add 1 to "clicked"
if clicked =o button =default
if clicked =1 button = state 1
......
.....
if clicked = or bigger than 4 set clicked to 0
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Tue Jun 10, 2014 1:13 pm

Roccinio wrote:Just add an instance variable example "clicked"
on clicked add 1 to "clicked"
if clicked =o button =default
if clicked =1 button = state 1
......
.....
if clicked = or bigger than 4 set clicked to 0


Oh, adding to a variable on each click... I was trying with all kinds of combinations using variables, but didn't try to actually add a number each click.
Thanks, I'll give it a try!
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Tue Jun 10, 2014 2:51 pm

Maybe I misunderstood something.
This is what I tried:

Difficulty.png


The default global variable Difficulty="Easy", while the default value for the variable Difficulty on the object DifficultyIcon=1. Frame 0=Easy, Frame 1=Medium, Frame 2=Hard. Howeverm this doesn't seem to be doing anything.
You do not have the required permissions to view the files attached to this post.
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Tue Jun 10, 2014 3:59 pm

they should not be nested inside the first condition.
on mouse clicked add 1 to difficulty

if difficulty =1 set animation frame to 1 and set system difficulty to medium
if difficulty =2 set animation frame to 2 and set system difficulty to hard
if difficulty =0 set animation frame to 3 and set system difficulty to easy

if difficulty is => 3 set difficulty to 0
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Tue Jun 10, 2014 4:53 pm

Roccinio wrote:they should not be nested inside the first condition.
on mouse clicked add 1 to difficulty

if difficulty =1 set animation frame to 1 and set system difficulty to medium
if difficulty =2 set animation frame to 2 and set system difficulty to hard
if difficulty =0 set animation frame to 3 and set system difficulty to easy

if difficulty is => 3 set difficulty to 0


Now I get it. Thanks a lot :)
B
14
S
3
Posts: 123
Reputation: 1,571


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly, Yahoo [Bot], zulerf and 6 guests