# Boolean global and local variables?

Discussion and feedback on Construct 2

### » Mon Feb 09, 2015 12:54 pm

For people trying to do booleans for right now here's two methods...

Method A:

If myVariable = 0 (IF FALSE)
If myVariable = 1 (IF TRUE)

Set myVariable = 1 - myVariable (TOGGLE BOOLEAN BETWEEN 1 AND 0)

Set myVariable = 0 (FALSE)
Set myVariable = 1 (TRUE)

Method B:

If myVariable = -1 (IF FALSE)
If myVariable = 1 (IF TRUE)

Set myVariable = myVariable * -1 (TOGGLE BOOLEAN BETWEEN 1 AND -1)

Set myVariable = -1 (FALSE)
Set myVariable = 1 (TRUE)
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

### » Mon Feb 09, 2015 4:34 pm

Jayjay wrote:For people trying to do booleans for right now here's two methods...

Method A:

If myVariable = 0 (IF FALSE)
If myVariable = 1 (IF TRUE)

Set myVariable = 1 - myVariable (TOGGLE BOOLEAN BETWEEN 1 AND 0)

Set myVariable = 0 (FALSE)
Set myVariable = 1 (TRUE)

Method B:

If myVariable = -1 (IF FALSE)
If myVariable = 1 (IF TRUE)

Set myVariable = myVariable * -1 (TOGGLE BOOLEAN BETWEEN 1 AND -1)

Set myVariable = -1 (FALSE)
Set myVariable = 1 (TRUE)

Even easeir

myVariable = 0
X myVariable = 0
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
71
S
19
G
19
Posts: 1,919
Reputation: 16,910

### » Mon Feb 09, 2015 9:09 pm

Toggle:

Set MyVariable = (MyVariable + 1) % 2

Normal use, just set it to 1 or 0....

Although not intuitive, there are bigger things that the editor/engine needs IMO.
...busy learning Unity - real lights etc!
(but c2 is easily the quickest way to make 2d html5 games)!
B
60
S
15
G
51
Posts: 2,086
Reputation: 33,692

### » Mon Feb 09, 2015 10:13 pm

easy method then variables just ad a sprite(can be you play button, main actor, a text something that stays on screen always and u don't destroy it ) and create a boolean for it , and make that sprite global now u have global boolean's ....... works for me , just i'm not using global boleans never needed one
B
48
S
12
G
46
Posts: 1,123
Reputation: 29,658

### » Tue Feb 10, 2015 8:09 am

gamecorpstudio wrote:easy method then variables just ad a sprite(can be you play button, main actor, a text something that stays on screen always and u don't destroy it ) and create a boolean for it , and make that sprite global now u have global boolean's ....... works for me , just i'm not using global boleans never needed one

Good idea, are global sprites limited in any way that global variables aren't or are they all exactly the same?
B
30
S
8
G
3
Posts: 598
Reputation: 4,468

### » Mon Mar 23, 2015 3:58 pm

Necrobump!

I'm just starting out with C2 and noticed this immediately (while implementing a work around for touch triggers firing ~simultaneously). Please address.
B
6
S
1
Posts: 17
Reputation: 334

### » Tue Oct 13, 2015 11:42 pm

* bump *

Yes we can do booleans with numbers, but it's not the same
B
4
Posts: 2
Reputation: 206

### » Wed Oct 14, 2015 6:24 am

i agree... integers take 4 bytes, bools 1 bit
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
29
S
10
G
11
Posts: 601
Reputation: 8,261

### » Tue Jan 05, 2016 9:06 pm

We have 2016 and it's still not implemented.
B
5
Posts: 4
Reputation: 235

### » Sun Feb 28, 2016 3:16 pm

Also just realised they are not there :'(
B
9
S
3
Posts: 102
Reputation: 1,041

PreviousNext

### Who is online

Users browsing this forum: tomi71 and 12 guests