Quick question about toggle buttons

Get help using Construct 2

Post » Tue Aug 05, 2014 8:19 am

I want to set up a similar toggle button system like the one used in Minecraft for difficulties and such. I have a "buttontext" family set up for the text on the button and set it to the same size and position as the button itself. Then I set up the following event system:

Image

When I click the button it doesn't do anything. Is there an easier (working) way to do this or is there something I'm doing wrong?

Thanks in advance,
LMillz
B
6
Posts: 30
Reputation: 292

Post » Tue Aug 05, 2014 10:10 am

Thats because condition one happens than condition to happens right after and both are valid.
you can change the second condition to else (x on the keyboard) then if the first condition is true it will not check the second one and vis versa.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Tue Aug 05, 2014 1:09 pm

Really? I thought when it is set up like that it goes in line and checks to see which one is true at the time. What do you recommend? An "OR Block"?
B
6
Posts: 30
Reputation: 292

Post » Tue Aug 05, 2014 1:32 pm

Try replace the second condition with an 'else'.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Aug 06, 2014 7:24 am

It says that an "else is not valid there.
B
6
Posts: 30
Reputation: 292

Post » Wed Aug 06, 2014 9:01 am

Read the manual more thorougly. Placing an else can be tricky at first.

And, it's a lot easier to get help if you upload a capx.

Edit: I might add, doing it this way (comparing text) is error prone. I would look at different ways of doing it, using a 'normal' numeric variable. Good luck.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Aug 06, 2014 10:18 am

Wouldn't using a boolean variable be much easier?

on textbutton clicked - toggle variable On
- if variable On is true - set text to "Bonus chest; On"
- if variable On is false - set text to "Bonus chest; Off"

You could also use a numeric variable
on button clicked set variable: 1-variable
that way you have the variable toggle between 1 and 0 too..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Aug 06, 2014 5:26 pm

test.capx

alright, this is the test capx i was experimenting these on. I have added 2 events so far to figure out how to get both of them going but as you can see when you click the difficulty one it changes the text to bonus chest. Ultimately what I am trying to do is have 2 buttons. A difficulty one that has 3 states (easy, normal, hard) and a bonus chest one that has 2 (on, off). I am obviously doing something wrong. I am probably going to change everything over to numeric variables but for some reason its only doing either button. not both.
Thanks
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 30
Reputation: 292

Post » Wed Aug 06, 2014 9:55 pm

Adding another button required a check on the 'else' to make sure which button we are dealing with. Then with the second button, just repeat what we did with the first. As you can see this method quickly gets cumbersome. There are some really good methods for handling buttons, you should search the tutorials.

Edit: 2nd capx combines into one event.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 07, 2014 6:20 am

I hate to be a pain but it isn't letting me open them because i don't have the beta release r176 :roll:
B
6
Posts: 30
Reputation: 292

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests