On / Off

Get help using Construct 2

Post » Fri Oct 12, 2012 10:51 pm

Hello all,

Just wondered what a good way to create a simple on off button would be?

Regards
B
3
Posts: 18
Reputation: 336

Post » Fri Oct 12, 2012 11:03 pm

It depends, there some ways

Global Variable = 0 means Off, 1 means On

For instances, create an instance variable and select Boolean, you can set true or false in event.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Fri Oct 12, 2012 11:13 pm

Create the item you want to use as the button (the button object or a sprite for example) Give it an instance variable called ONOFF (could be anything you want) and set it as BOOLEAN. Then on clicked with the mouse use the TOGGGLE BOOLEAN option. This will switch the FALSE (default value) to TRUE. Clicking again will switch it back ... and so on.

You just need to test for the value of the instance boolean variable.

Easier to show that describe so I knocked this up :) Hope it helps.

CAPX

DEMO
B
19
S
5
G
4
Posts: 208
Reputation: 3,960

Post » Sat Oct 13, 2012 2:23 am

Mouse Right Click : Insert New Object /// Form Controls | Button
As Easy as this ...
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Sat Oct 13, 2012 2:16 pm

Thank you all that has worked a charm, never knew about inverting.
B
3
Posts: 18
Reputation: 336


Return to How do I....?

Who is online

Users browsing this forum: PixelatedTrip, Yahoo [Bot] and 0 guests