How to make a flashlight effect?

Chat about anything not covered in these forums, but keep it civil!

Post » Wed Mar 31, 2010 3:19 pm

Im looking for ways to make say a flashlight kind of effect and im wondering if anyone can point me how to do it? I tried doing it with a dynamic lightning but i cant seem to get it to work.. Any suggestions or examples would be very helpful :D
B
2
S
1
G
3
Posts: 49
Reputation: 1,098

Post » Wed Mar 31, 2010 3:58 pm

Hey,

I've done a bit of tinkering around with this problem too. Here's one way to do it (though there are probably more, way prettier ways to do it. for example check out madsters "Dark Asteroids" game):

Take a look at this cap. Arrow keys move, mouse points flashlight.

Basically for my solution you need at least two layers. The top one needs to have the Multiply effect on it. Then create a white gradient in some sort of graphics program like the GIMP in the shape that you want your flashlight to have. In the cap, I've made the gradient larger around the player so you can see what you're doing. The layer beneath the top one should have your game elements like your player, etc.

You can stop there, but in the cap, you'll see that i've added a light object and some shadow caster objects. Take careful note how the layers are set up and what is in them.

Hope this helps.
B
2
G
3
Posts: 52
Reputation: 954

Post » Thu Feb 03, 2011 4:50 am

Aside from the suggestions in this forum, you also have to research for the proper procedure. Flashlight effect is one of the good things to be done. You should be knowledgeable in doing this.
B
1
G
1
Posts: 2
Reputation: 429

Post » Thu Feb 03, 2011 5:10 am

Add a new layer, untick 'transparent' in the layer properties - make a white spot light sprite, then make that layer use 'multiply'. Instead of a sprite, if you want shadows, you can use the light object and add shadow caster behaviours to the objects that need to cast shadows.
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sun Mar 27, 2011 4:16 pm

Hey,

sorry to dig up this old thread, but I found it via the search and thers that may find this too should maybe know this:
To make this work with tiled backgrounds, you have to use a block-element (no sprite) with shadow-caster behaviour and properties "solid", and the sprite or tiled background on top of that (work with layers here, because you aren't allowed to make the shadow-caster block just beneath the tiled-background on the same layer - it leads to strange results). Making the shadow-caster block invisible at runtime via events also don't work, the shadow-caster element will need to be visible (although beneath another sprite/tiled background) to cast a shadow.

I used different blocks with standardized heights (50 for walls, 10 for high objects, 1-2 for obstacles like crates etc).
B
3
G
2
Posts: 35
Reputation: 770


Return to Open Topic

Who is online

Users browsing this forum: Theflash5753 and 8 guests