Boolean global and local variables?

Discussion and feedback on Construct 2

Post » 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
88
S
29
G
13
Posts: 2,098
Reputation: 15,171

Post » 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
72
S
19
G
19
Posts: 1,921
Reputation: 16,939

Post » 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.
B
63
S
15
G
57
Posts: 2,138
Reputation: 36,863

Post » 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
ImageImage
B
54
S
14
G
64
Posts: 1,252
Reputation: 39,495

Post » 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
34
S
9
G
5
Posts: 728
Reputation: 5,940

Post » 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

Post » Tue Oct 13, 2015 11:42 pm

* bump *

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

Post » 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
30
S
10
G
11
Posts: 603
Reputation: 8,290

Post » Tue Jan 05, 2016 9:06 pm

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

Post » Sun Feb 28, 2016 3:16 pm

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

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests