The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

I want to create sprite masks but I want to reveal another sprite when I hover my mouse over a sprite. Here is the video of the same but in Unity: https://www.youtube.com/watch?v=4pl8DcsCQ_k

I tried using mask in light 2d but I couldn't proceed any further since I am still a beginner to game development

in Engine by (18 points)

2 Answers

0 votes

You can do it with a scene comprised of 2 sprites and an Area2D node. Give the Area2D a child of CollisionObject2D and set it's shape to a rectangle covering the sprites so that everything is overlapping.

Add an empty script to the scene root Node2D. Then connect the mouseentered and mouseexited signals of the Area2D to the script.

Then add getchild(1).hide() and getchild(1).show() to each of the script functions that handle the signals.

Now the top-most sprite will toggle it's visibility on/off as the mouse moves over it. Save the scene and instance it in other scenes where you need it.

You can add export vars for textures to set the sprite textures later when you instance the scene in other scenes.

by (72 points)
+1 vote

Take a look at my answer over here.

by (10,634 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.