OR block bug

Bugs will be moved here once resolved.

Post » Sun Apr 17, 2016 8:21 pm

Problem Description
OR blocks are not properly registering as a TRUE condition when one or more of the condition lines indicates TRUE.

Attach a Capx
link to capx

Description of Capx
The layout contains a TiledBackground (TB) and a sprite (with 8-direction behaviour, so you can move the sprite to overlap the TB). There are 3 groups in the event sheet, 2 of them are disabled so that only one group runs during testing.

If the mouse or the sprite overlaps the TB then it is set invisible. Group 1 works correctly with separate events to check for the overlaps. Groups 2 and 3 contain OR block checks of the mouse + sprite overlap, with the order of the conditions swapped in each group.

Steps to Reproduce Bug
  • Run the layout with only Group2 enabled and observe when the TB is set invisible with mouse / sprite overlapping it.
  • Run the layout with only Group3 enabled and observe when the TB is set invisible with mouse / sprite overlapping it.

Observed Result
As described in the Group comments, the OR blocks in Groups 2 and 3 do not work correctly. The Group2 OR block works like an AND (sort-of...), and the Group3 works only when there is a mouse overlap.

Expected Result
Each OR block should register as TRUE if one or more of the lines in the block registers as TRUE.

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)

Operating System and Service Pack
W10 x64

Construct 2 Version ID
r227 64 bit
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Mon Apr 18, 2016 5:30 am

I tested it and indeed looks like a bug. At first I thought it was a problem with using Else in Or blocks, but the bug happens without it too: https://dl.dropboxusercontent.com/u/395 ... rBug2.capx
In one of the cases it works like AND and in the other only the mouse event is detected
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Sun Apr 24, 2016 9:50 am

Was having problems with this and I have now seen this report, must publish soon be a correction !.
B
29
S
12
G
21
Posts: 801
Reputation: 14,453

Post » Sun Apr 24, 2016 11:27 am

I think you read those conditions the wrong way.
Maybe you understand this example better:

https://
drive.google.com/open?id=0B1SSuCVV8v74YlBUdzI3dzhlQ28

The thing is. This is not a logic puzzle like the easy if x=4 or if x=5 then do this.

This is are pick conditions. Its not comparing overlaps. It is making Selected Object Lists. And that is all it does.
The overlap logic is only in your mind, its is not part of the logic.

The question with pick condition is always simple: what is in previous Selected Object List. And what did we filter out (or not) in the next pick condition.

Okay so:

Sprite is overlapping tiledbackground ...

1/ if the sprite is overlapping, both sprite and tiledbackground are in the SOL. This made the previous picked SOL for the next pickevent. If now the mouse is not over the background, that background dissapears in the SOL. Simple as that.

2/ if the sprite is not overlapping the tiledbackground, the SOL is empty, it does not matter what the mouse does, the tiledbackground is just not in the SOL to begin with. Simple as that.

3/ if the sprite is overlapping, both sprite and tiledbackground are in the SOL. If now the mouse is over the background, that tiledbackground stays in the SOL. And finaly the tiledbackground that is in the SOL gets set invisible. And that is why you see this as an AND event. While it is not.

There is a BIG difference in logic between pick-events and non-pick-events.

The only thing that pick-events do is filter previous picked Selected Object Lists. And the previous picked Selected Object List is empty when a new root event is started.

And that is in 2 sentences all you need to know to make good pick events.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Apr 24, 2016 11:37 am

My opinion (everyone has one) on this is this:

Since you have to code this differend to make a solid logic, Construct 2 can as wel force you to code this differend. By not allowing an 'OR' when there is a pickcondition in the events.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Apr 24, 2016 12:42 pm

@99Instances2Go,

According to the manual, if any condition in an OR block is true then the sub-events should be run.

Here's another example to demonstrate the bug: capx demo 2.

The group "works for cursor overlap" runs correctly because the overlap check condition reads true (ie the cursor overlap condition = 1). So we have a condition that reads as 1 when on its own or under an Else, yet it does not read as 1 if it is placed inside an OR block.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sun Apr 24, 2016 1:48 pm

There is no false/true case. It just adds or pulls objects on/from a stack. The actions run on the stack.

The result of a pick condition like 'is overlapping' is not a true or false flag, the result is a list of objects, populated or empty.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Apr 24, 2016 2:24 pm

99Instances2Go wrote:The result of a pick condition like 'is overlapping' is not a true or false flag, the result is a list of objects, populated or empty.


Let's agree to differ on this point and see what Ashley says. I am pretty certain that if the SOL is not empty then the condition should behave as if it was true. This is why, in fact, in my second example above (line 6: Else, Cursor is over Sprite) the condition is true and the variable changes to 1 whenever the mouse is over the sprite (ie the SOL is not empty).

Additionally, your analysis does not explain any of the nuances of this bug (ie the order of the conditions in the OR block makes a difference as well).
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sun Apr 24, 2016 3:23 pm

I have to rephrase things. I was only half correct. The flag true/false gets set. Else unreferenced objects would not feel the action, and they do. But. The rules for picking still apply. The SOL is just empty. The action run on a empty SOL.

https://www.scirra.com/manual/75/how-events-work
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Apr 24, 2016 3:38 pm

@99Instances2Go,

I've edited the original capx, please re-download and take a look. There is definitely a picking problem caused by the presence and position of the mouse-overlap check condition.

I have added a text object that changes to indicate if the OR block is running as TRUE or FALSE. The tiled background should be picked by the overlap with the sprite, but this is not happening - even though the text object is changing to indicate the condition was True.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 6 guests