[Canvas] Dynamic Lights and Shadows: Add static Lights

0 favourites
  • 10 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • No one has an idea?

    I am considering the canvas plugin to remove, but how can I prevent the light shines through the walls?

  • 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.

  • 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.

  • 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!

  • 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...

  • 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?

  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)