Layer Scroll Rates and Tile Based Lighting

Get help using Construct 2

Post » Mon Oct 15, 2012 7:10 pm

Hey guys, quick question...

I've created a tile-based lighting system (similar to minecraft/terraria) but I'm also using parallax scrolling to create depth, because the light sources are in different layers, their "reflected light" appears on layers with different scroll rates, and therefore becomes detached visually from the light source. Does anyone know a way I can compensate for this?

Thanks in advance
Brent
B
70
S
10
G
9
Posts: 300
Reputation: 8,962

Post » Mon Oct 15, 2012 11:23 pm

A guy in chat and I were working on this a while back. Here's the formula.

X = self.OriginalX + (scrollX - scroll_OriginalX) * (1-ParallaxAmount)

That works for keeping something 'stationary' superimposed on the parallax layer. Same for Y, obviously.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,709

Post » Tue Oct 16, 2012 12:35 am

I'll give that a try, thanks for the reply!!
B
70
S
10
G
9
Posts: 300
Reputation: 8,962

Post » Tue Oct 16, 2012 2:09 am

Let me know if it doesn't work!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,709

Post » Tue Oct 16, 2012 9:31 am

I'm afraid I'm not quite sure what you mean in the formula "scroll_OriginalX" where is this being referenced from?
B
70
S
10
G
9
Posts: 300
Reputation: 8,962

Post » Tue Oct 16, 2012 9:59 am

I managed to tweak the formula you offered and achieved the exact results I wanted, thank you for your help. What I wound up using was X = OriginalX + (ScrollX * ScrollRate (in this case 50%) * offset (as my object appeared to the left of where they needed to be but scrolled properly) so thank you again for the assistance!!

here's how it turned out :)

https://dl.dropbox.com/u/4075855/Tile-Based%20Lighting%20Test/index.html
B
70
S
10
G
9
Posts: 300
Reputation: 8,962

Post » Wed Oct 17, 2012 11:30 am

Cool, glad it got working.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,709


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 26 guests