2D Flashlight for a platformer

All of this is for a 2D platformer, fyi. I’m trying to make a flashlight for my main character (the world is completely unlit and this is how they see). Obviously, the light need to bounce off the floor, ceiling, and everything thing else in my environment (which are all sprites) and illuminate what is in it’s path before that (for instance the back wall). Also, the beam of light needs to be able to easily change color. Also, for the record, you can’t see the main character just the beam.

What I’ve been trying to implement is a spot light attached to the main character sprite (which is nothing, just a placeholder) that is in front of the sprites on the z axis. It doesn’t seem to do anything there, despite seemingly hitting a background sprite that I have.

Just wondering if someone has any insight as to how to make this work, or a better way of going about making the flashlight beam. Thanks much.

Convert this into 2D. I'm sure you can figure out how to do it from there. This guy also posts all of his code online and talks you through how to do it. It is in 3D but converting it isn't terribly hard.

2D Flashlight Editor: