Moving in and out of shadow

For questions about using Classic.

Post » Sun May 13, 2012 3:17 am

I'm having a fairly unique problem, but I just have no idea how to fix it. I've created a family called 'shadows' and when an object is overlapping one of the objects in this family, it is given a grey colour filter and when it is not overlapping a 'shadow' object it is given a white colour filter (i.e. no colour filter).

This worked when I had only one object (the player) that was moving in and out of shadows. Now it seems, after I've added some other objects (the rocks) overlapping the shadows, the player object does not lose the grey filter when it leaves the shadows.

To make things more clear, I've included a .cap file. I realise this is a small problem in the grand scheme of things, but its one I have no idea how to fix.

.cap download

The events in question are in the 'terrain events' event sheet.
B
3
S
1
G
3
Posts: 105
Reputation: 1,312

Post » Sun May 13, 2012 4:37 am

I think it is a bug with else condition, i fixed it using 2 conditions:
If Terrain overlaps Shadows And Value "Nodarken" == 0 > Set filter to Gray

(INVERTED)If Terrain overlaps Shadows > Set filter to White

Metal_X2012-05-13 04:38:21
B
22
S
7
G
5
Posts: 90
Reputation: 3,430

Post » Sun May 13, 2012 5:03 am

Ah, I can't believe I didn't try that. Thanks a million :)
B
3
S
1
G
3
Posts: 105
Reputation: 1,312

Post » Sun May 13, 2012 2:38 pm

No, there isn't any bug with the else-condition. While it is working correct, the logic behind the creation of the events is incorrect.

Let's have a closer look at it:

+ Terrain: Terrain overlaps Shadows
+ Terrain: Value 'Nodarken' Equal to 0
-> Terrain: Set filter to
+ System: Else
-> Terrain: Set filter to

On every tick CC is ordered to check if any Terrain overlaps any shadow. Of those, only the ones with the correct value of the pv are picked. This selection of objects get a grey filter.
But using 'else' here means that only if NO terrain is overlapping any shadow, all terrains will get the white filter.

As you can see in your layout, there are several instances of 'Whiterock2' that always overlap a shadow object, so the else-branch will never be executed, because the first conditions are always true.

Currently all terrain objects are tested on every tick. Unless it isn't so, you can (besides Metal_X's solution) also do it just like this:

+ System: Always (every tick)
-> Terrain: Set filter to white

+ Terrain: Terrain overlaps Shadows
+ Terrain: Value 'Nodarken' Equal to 0
-> Terrain: Set filter to grey
tulamide2012-05-13 14:40:10
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests