So I've built this little thingy for lighting...

  • Hey there,

    I've been working on a way to add fancy dynamic lighting to my current game project and wanted to share my little demo project.

    The general idea (put a layer of darkness over everything and then stamp out the light) has been the standard method for quite a while, but I didn't like that this darkness would just lay over everything. So, now it's possible to define where your darkness should be. The rest has already been done before, but as the respective forum in flashgame dojo is no longer available, it doesn't hurt to bring it back up again.


    • Defined areas of darkness: Create a layer of darkness out of selected Tilemaps, static and animated sprites, but leave out all the transparent parts and areas not covered by the selected items. Useful for building windows.

    • Light moods: Your darkness can also work as a colored light mood, by turning the scene in red, golden or bluish light. The color and intensity of the darkness can even change over time.

    • Colored Lights: Your darkness can be illuminated by lights of all colors, and objects within that light cone will receive the respective tint.

    • Dynamic lighting: Both your light sources and your to-be-lighted objects can move around the screen.

    • Animated lighting: You want a light source that casts a flickering light like a camp fire? No problem.

    Here is a link to the github project.
    It might be required to set one or two variables from the flixel base classes from private to public in order for it to work!
    (uses flixel dev build 4.0.1)

    And here a link directly to the flash build.

    Have fun!

  • Here are some picturess of how the result looks:


    moonlit night

    dark night

  • Woah it looks awesome! Thanks for sharing!

  • Nice!

    But it is crashing on android and windows.

  • Huh. Sorry about that. Never tried it with anything besides a flash build; with HTML5, the necessary MULTIPLY-blendmode doesn't seem to work and performance becomes unbearable.

  • Fantastic work mate! Glad you tackled the issue with tinting those animating sprites :) - I think can be somewhat fixed for CPP, since I noticed there was a lighting demo (waaay simpler than this) which worked. Although the method was different, so I'm not sure. Kudos on getting it working!

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.