Flags

New releases and general discussions.

Post » Thu Oct 23, 2008 7:42 am

Is this a possibility for objects? It's kind of tiring always having to use variables when all you want to do is to just easily toggle between an 'on' and 'off' state for sprites etc.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Thu Oct 23, 2008 8:26 am

Since Construct is a much more DIY game maker than most (well, some), then if this feature were to be implemented, you'd probably have to be setting up the flags yourself anyway, in the same sort of manner that variables are set up. It would be just as easy to set up a variable. And it would be just as easy to make a "set flag to off" action as it is to make a "set value to 0" action.

And even if you were to have some flags set up for you automatically, what would be a good amount? Five? Ten? Who can say? There's really no good answer for something like that, everyone has different needs for their games. So the logical answer would be to not have any set up automatically, and have the user set up their own flags as needed. Which brings us back to point #1.

I don't mean to be a naysayer, I'm just wondering what advantage flags would have over variables. A flag is pretty much just a binary variable anyway. Variables can do the same thing, but also much more. So I really can't see a reason why you would want to introduce a new feature that, in essence, is just a crippled version of a current feature.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 23, 2008 10:12 am

Even though flags are not neccesary, they would play a big role in making code easier to understand. When I've flags achieved by conditions:
:arrow: ('myVal') is greater than 0
:arrow: ('myVal') is lower or equal 0
Or:
:arrow: ('myVal') is equal to 1
:arrow: ('myVal') is equal to 0
Or some other solutions... they all still look harded to see than "TRUE" and "FALSE". This is a big help in organizing your code. But I think that "Flags" are not of greatest importance at the moment.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Thu Oct 23, 2008 12:26 pm

Yep...
I too, at the start was the same...
but, well, there's no need for it, if you can make how many vars you whant...

this is far away from making me to care about... but the worst for me without a doubt are those events to change anims... cus thei're not working too well... XD
B
2
G
4
Posts: 27
Reputation: 1,104

Post » Thu Oct 23, 2008 12:50 pm

I personally just use number variables for flags - 1 for on and 0 for off. I'm perfectly comfortable using it considering I'm from a programming background, but if you prefer, you could just as easily use text like "yes"/"no", "y"/"n", "on"/"off", "true"/"false" etc...

If you use a number you can toggle it with 1 - value (1 - 1 = 0, 1 - 0 = 1), or with text you could still use: value = "yes" ? "no" : "yes"
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Tue Oct 28, 2008 12:36 pm

Just to pitch in here:

Personally I don't see flags as necessary; they'd need to be set up via properties anyways, so it's just some more clutter. Variables are the proper solution, just switch between 1 and 0 like Ashley said.

One thing that could be done is boolean variables (using a combobox with On/Off or so in it), I'd imagine that'd be easy to add.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue Oct 28, 2008 2:14 pm

Yeah thanks for clearing all this up guys :wink: . Just wanted to know the reasons 8)
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Wed Oct 29, 2008 11:18 pm

The one thing flags are easier for is that you can "toggle" them, but that could easily be achieved with a simple Else event.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Thu Nov 13, 2008 9:06 am

I think true and false should be keywords in expressions.

Set 'Myvalue' to true

And it would be identical to

Set 'Myvalue' to 1.

only problem would be that true + true would equal 2 though :P
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Thu Nov 13, 2008 12:07 pm

Agree with David, that's definitely sensible.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests