|Topic was automatically imported from the old Question2Answer platform.
I want to make a light when touch or click,for example all the screen is dark but when I touch in any part it will illuminate (so the player can watch the game) in a radius but only for one second, then the ligth start go off slowly. When I touch the light starts expanding in a radius and after one second It will start go off, but i dont have idea how to do it, can anyone help?
Here’s how I think you can solve your problem.
- Have a light node of some kind (e.g. a
Light2D) that has an
Area2D attached to it. Set the signal of the
body_entered signals, whichever one you’re using for your character) to be emitted when the character enters the
Area2D or when the player clicks on the
- Set the
Light2D to “visible” when the character enters the
Area2D. The expansion part is a bit more difficult, becasuse
Light2D requires a texture to define which parts are lighted (it’s a grayscale image with values in between white and black). You may have to write a shader to make that expand.
- Once that expansion problem has been solved, set a
Timer and use the
timeout() signal of the
Timer to make the
Light2D invisible after 1 second.
For more information on lights and shadows, see the official documentation on the subject. With regards to Signals, see the documentation on that subject. Finally, learn more about
Area2Ds from the documentation.