[Canvas] Dynamic Lights and Shadows: Add static Lights

Get help using Construct 2

Post » Fri Feb 21, 2014 9:53 am

Hello,
i have a little problem with the following plugin. I use this plugin for dynamic lights and shadows:
viewtopic.php?t=64239&start=0

...and here is the *.capx file:
https://www.dropbox.com/s/8szoexmh8j9rm ... adows.capx

The plugin actually works quite well, but I would add static light sources. In the demo you can see that "target" (e.q. flashlight) always has the position of the cursor. How can I add static light (e.g. lamp) now? I hope you understand and can help me. Thanks a lot!
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Sat Feb 22, 2014 4:08 pm

Ok, nobody can help me?!

I have added two screens of my event sheet, because i don't want to upload the original *.capx file (more than ~60 mb)
So, this code works on start of layout: https://www.dropbox.com/s/01etrayx5n4ir ... mapper.jpg
...and this on every thick: https://www.dropbox.com/s/nar7ain7bcljv ... -paths.jpg

I think the "canvas plugin" has a poor performance on larger maps. Is there another way to represent shadows? Can I optimize the code so that the light points are generated only when I really need it or can I scale down the canvas object (currently a size of 2000 pixel) and pin it? I hope someone can help me! :)
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Tue Feb 25, 2014 8:56 am

No one has an idea? :(
I am considering the canvas plugin to remove, but how can I prevent the light shines through the walls?
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Tue Feb 25, 2014 9:08 am

Shadows... dynamic light... well, it's a hard subject.
Canvas plugin did have a high performance influence last time I used it (for the exact same reason as you did). I don't know of any workaround that could help with this right now. I did some research and tries with the illuminated.js script, but didn't manage to make a plugin out of it.
But, in your first post, you asked for static lights like a lamp. This particular case is quite simple and doesn't require canvas at all.
Here is an example on how to do a simple static light.
Edit : highlight on the method :
- a layer "lights", black, not transparent, on top of the game.
- add a multiply effect to this layer
- add white sprites (or colored ones if you want red, green and other lights) in this layer
The multiply will make everything black in your game, except what is lighten.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Tue Feb 25, 2014 10:06 am

Oh, the illuminated.js is exactly what I want! But how I can make this in C2? In need this absolutely for my game. :)
greweb.me/illuminated.js

That with the colored lights is great. Thanks for this tip. ;)
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Mon Mar 03, 2014 1:28 pm

Ok, I was searching for "shadow caster" and I have found this:
scirra.com/forum/viewtopic.php?t=88188&start=0

I have download and modify the *.capx file - here is it:
dropbox.com/s/bjnf805uinbrpk3/Shadow_Caster_Modified.capx

That look already fine, but I have some issues! How I can change the color of lights and how I can make a background (e.g. a texture) visible?! Thank you for help!
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Mon Mar 03, 2014 1:45 pm

@wossi

For changing the color, just look at the event 2 action. The color is a local variable on each Light object, you can change it there.
As for the background, I can't help you, I don't know.

Just so you know, on a classic office computer (no fancy graphic card, 2GB RAM), this project got my firefox and chrome to crash. Canvas takes a lot of resources on top of C2...
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Mon Mar 03, 2014 2:15 pm

I know the canvas needs a lot of resources, but I find no other solution for dynamic shadow effects. If you know any other way, then you can betray me quiet. ;) I'm working on a top-down survival game, and since I need these effects. If the game is not really good, then I throw my money for C2.

Can you tell me the name of the variable, I can not find them?
B
9
S
4
Posts: 103
Reputation: 1,195

Post » Mon Mar 03, 2014 2:19 pm

In the last project you shared, the variable is an instance variable on the objects "light", and its name is ... "color".

As for other solutions, no I don't. I ran into the same exact problem (top down, stealth game), and used another light system, a lot less attractive (no light around corners possible at all, light was going only on X and Y axis...). It won't be your solution.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Mon Mar 03, 2014 2:38 pm

Ah, thank You I overlooked the variable. :)
I work with very large maps, so the canvas must also have this size (currently I am working with 1920x1080) ... I try somehow to make the canvas smaller, so as to save power. I hope I succeed sometime :D
B
9
S
4
Posts: 103
Reputation: 1,195


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests