Boolean global and local variables?

Discussion and feedback on Construct 2

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
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

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.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,215
Reputation: 43,852

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
B
75
S
22
G
69
Posts: 1,341
Reputation: 43,779

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
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

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
42
S
14
G
12
Posts: 624
Reputation: 9,421

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
10
S
3
Posts: 109
Reputation: 1,080

Post » Sun Feb 28, 2016 4:46 pm

Would it be an issue for it to be rolled out for a quick update?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests