events run in groups even after deactivation

New releases and general discussions.

Post » Sun May 04, 2008 11:42 pm

Is this how it's supposed to work? It seems conditional: mouse clicks in a group of events won't run after a 'deactivate this group' command is run, but if an object collides with another object in a later event after construct has been told to deactivate the group, the event still runs. Such as:

Group 1
Always set sprite y to sprite.y+1

Sprite overlaps sprite 2: System: Disable group "Group 1"

Sprite overlaps sprite 2: Sprite: rotate 10 degrees clockwise

...the sprite still rotates. I would prefer construct stops running events in a deactivated group, rather than continuing through and deactivating upon the next run-through.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon May 05, 2008 2:14 am

Is there an earlier event triggering the group back on, conflicting? Ya know, like the button color change thread from a few days ago?
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Mon May 05, 2008 3:47 pm

In the example I wrote, no. There's no event to activate the group at all. I'm sure you meant in the game I found this with, but the example shows what I mean. In the game I'm working on, the events to activate that group are later in the group that's supposed to be deactivated, so they shouldn't run.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon May 05, 2008 3:50 pm

upload the .cap I think ;)
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Mon May 05, 2008 3:57 pm

Well, the activation of a group currently acts like a big 'if' statement. The activation state of the group is only checked at the top of the group, and if it is activated, all its events get run. Consider the event:

+ Global variable 'Myvar' = 0
> Action 1
> Set 'Myvar' to 1
> Action 2

Even though the action 'Set 'Myvar' to 1' makes the condition of the event false, this does not cancel the running of the event; Action 2 is still run even though the event is no longer true. It's simply because the conditions are checked once only, and all actions are run when that check is true.

The logic is the same with groups, and I'm not convinced it should be changed, since this behavior exists in other places in Construct. You could work around it by adding 'Group is activated' conditions to the subsequent events after a deactivate.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon May 05, 2008 7:39 pm

Edit: misread reply.

There are a whole lot of events after those, though. Doesn't that kind of make it a little redundant, asking an event to check if the group it's in is even active? Isn't that the point of deactivating the group?

Regardless, I'm happy to use the 'group is activated' condition - I can't find it anywhere, though.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon May 05, 2008 8:30 pm

Haha, I think I forgot to add that condition :oops:

I'll put it in the next build. You can also make all the rest of the events in the group a subevent to a "group is activated" condition - when it's done - saving you repeating the condition in every event.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon May 05, 2008 10:41 pm

Oh, great idea. Much appreciated! :D
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest