Waders,
This is a near duplicate of a post in: 'How to use Wade' - Flashlight effect.
With a little help form Gio, I put together a little demo of how to make a flashlight effect with wade
It is up on the projects page - Flashlight Demo
A few general things to note:
- I can't seem to turn the tank unless I run the demo in full screen mode.
- The night effect is just a purple rectangle - I just filled an image in photoshop with the color at 50% opacity
- The flashlight is just a white triangle(ish) shape - you could play around with this shape / color to get different light effects.
In the code:
- The message layer is a lower number than the dark layer which is lower than the game layer. If you understand wade layers then duh, if you don't, go read about wade layers
- The dark layer resolution factor is set to 0.1. To maintain performance but I'm not sure how this would perform on a mobile.
- If using destination-out in the composite draw function, the nightEffect sprite has to be behind the flashlight sprite. In other words, the order of the sprites on the layers matter. Refer to the diagram near the bottom of this page, html canvas to understand how the composite draw functions make foreground and background images interact
Anyway, this could be a nice easy effect to add to your games.
cheers,
Shri