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! (but not play them)" Construct Classic - Examples Kit
B
95
S
33
G
14
Posts: 2,117
Reputation: 16,487

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
73
S
20
G
19
Posts: 1,927
Reputation: 17,076

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
16
G
62
Posts: 2,169
Reputation: 39,483

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
55
S
14
G
64
Posts: 1,258
Reputation: 39,571

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
37
S
11
G
9
Posts: 948
Reputation: 8,399

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
32
S
11
G
11
Posts: 610
Reputation: 8,489

Post » Tue Jan 05, 2016 9:06 pm

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

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 2 guests