The following files have been attached to this tutorial:
This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.
Method 3 - Light in an arc
Have a look at "Cast light arc 01" - This shows the last method I have been using to cast light/shadows. Run the program and move the mouse/sprite over the arc of red "light".
All this is doing is creating a long thin sprite "my light beam" and moving it through a set number of degrees. When this light beam touches an obstacle that particular light beam is destroyed.
A rather obvious problem is we are now left with a triangular shadow coming from the obstacle to the light source.
A simple solution to this is to reduce the light beams length on striking an object.
(see cast arc light reducing length.capx)
Note that I have each light beam set to fade out - there are other ways to do this but this is simple and it works.
To incorporate this method into a game then the light you would need to move these beams onto another layer and set the blend as previously discussed. The arc start point would need to be placed where the player is and the arc angle would need to take the players angle into account.
(Cast forwards 3.capx)
Well I guess that will do. Please leave a message with any question, comments or suggestions.
edit 6th April, 2014.
Added a couple more capx for you to have a look at - one cuts up the light into sections to get around the problem of long walls and the other is the fog test (see below). Both could do with tidying up and commenting...