Making own flashlight

Started by Rd27, Tue 24/06/2008 15:19:47

Previous topic - Next topic

Rd27

I want to make own flashlight effect but I don't know how :(

I have made many seacrhes and found this what dkh wrote in flashlight plugin thread:

create a GUI with a black rectange that has a transparent circle in it and position this GUI so, that the center of the circle is always where the mouse currently is. That's just a bit of playing around with offset values, and then you can enable or disable your flashlight by showing or hiding this GUI.

So do I just do new gui which is black, that is rectangle is it...

How do I make the transparent circle to the gui? Do I make it with paint program like Paint shop pro or what?
And how do I center the circle so that the mouse cursor is center of the circle. With offset values, but don't know excatly how...

Finally, do I move the flashlight with the gui.setposition(mouse.x,mouse.y); ?





Matti

Yes, make a sprite with a circle of the transparent color in the middle.

If the rectangle is 400x400 then put in on (mouse.x-200, mouse.y-200) in the rep.-ex section. Then it should be centered if I don't mess up things right now.

Khris

For a 320x200 game, you'll need a 639x399 GUI.
To get a black GUI with a transparent center, create a new picture with a black background, 639x400.
Draw a filled circle with its center at 319;200, then use the same color to draw a horizontal line going from 0;0 to 639;0.
Now import the sprite with transparency setting top-left pixel, then crop it. You'll end up with a 639x399 sprite with a transparent hole in the center. Use that as GUI background.
The GUI is then to be placed at mouse.x-319, mouse.y-199.

You could even smooth the 'hole' by using an appropriate alpha channel.

Rd27

I got it working in 320x200 resolution just fine.

But how do I do the same trick in 800x600?

I tried the same method with 800x600 in mind ofcourse, but result was something unwanted :P

TwinMoon

Quote from: Rd27 on Tue 24/06/2008 22:05:13
I tried the same method with 800x600 in mind ofcourse, but result was something unwanted :P

Like what? We're no mindreaders!

Just to be sure, in 800x600:
- the gui image needs to be 1599x1199
- the center of the circle in the image should be at 800;600
- place the gui at mouse.x-799, mouse.y-599

Rd27

#5
Quote from: TwinMoon on Tue 24/06/2008 22:25:25
Like what? We're no mindreaders!

Really? :)

I tried excatly liked that before, and the result was something really not what it supposed to be.
The circle weren't even near the mouse cursor.

So I wonder what is wrong...?

EDIT: I got it working now the way it should be.
Thanks to all the helpers!

Rd27

#6
Well, like I said the flashlight now works, but now I realised that I can't click on any hotspots and stuff like that. That's probably because the gui is on top of them?

So I believe that there is a solution to this so I don't have to always turn the gui off to be able to interact with the stuff on the screen?

A big thanks to who give the solution to this :)

GarageGothic

#7
Change the GUI's "clickable" property, like so:

Code: ags
gFlashlight.Clickable = 0; //assuming the GUI's script name is gFlashlight


Or just change the property directly from the GUI setup in the editor itself.

Rd27

Doh, I feel like stupid now...

Thanks to you GarageGothic :)

Maverick

Hi,

This module may help you to further enhance your flashlight. Code might still be AGS 2.72 but it should not be too far off.

Cheers

SMF spam blocked by CleanTalk