Lets look at version two ("Part 3 simple.capx")
So every tick we :
set our light image to where the mouse is
find out how far to the left (or right) the light is compared to the building simple by taking the mouse x position away from the building x postion this gives us the distance and the direction (a positive result show that the mouse is to the left, negative to the right) and we set this to a global variable called gvLightOffSetX
do the same for up and down offset (gvLightOffsetY)
then we offset the shadow from the buildings position by adding the gvLightOffsetX and gvLightOffsetY to the buildings x and y location.
Try changing gvShadowOffset at the top of the sheet from 10 to 1 or 5 or 20 and see what happens. Using different values here creates different offset amounts. Could be used to cast a shadow from a plane onto the ground below - alter the shadow offset to simulate the planes height ...
Finally in "Part 3 with layers.capx" :
We add a Shadow layer
We use an alpha image on "Layer Shadow" to see through this layer to the main layer below.
We constantly update the alphas x and y position to match the mouse x and y.
I am going to post this now - it is not finished but I will edit in the extra bits as I go along. I thought I would have had this finished by now and at this rate it will be the weekend at best - so have a read of this to be going on with.
I'll be back...
I'm back !