Hey,
I made simple item tooltip in my game. Just basic node (stored in separate scene) which shows itself when mouse is over item. Idea is simple:
On my main UI scene i have nodes (item list and some panels) connected to signals "on mouse enter" and "on mouse exit". Enter signal changes variable in my singleton to some number, and exit signal changes variable to 0.
On my tooltip scene script I have some code in process method which shows tooltip when singleton variable is greater than 0. Tooltip script below.
func _process(number):
if (PlayerMemory.item_to_tooltip > 0 and PlayerMemory.item_to_tooltip != ChosenItemId):
ChosenItemId = PlayerMemory.item_to_tooltip
ChosenItemData = DataTables.get_item(str(PlayerMemory.item_to_tooltip))
Icon.texture = load(ChosenItemData.icon)
Name.text = ChosenItemData.name
if (PlayerMemory.item_to_tooltip > 0 and !self.is_visible()):
self.visible = true
if (PlayerMemory.item_to_tooltip > 0 and self.is_visible()):
self.rect_position = get_global_mouse_position()
if PlayerMemory.item_to_tooltip == 0:
ChosenItemId = 0
ChosenItemData = {}
self.visible = false
Simple. And it works. But not perfect.
The problem: when mouse is in motion, and it moves in "positive" direction (down or right) then my tooltip is blinking. May not be visible on gif below, but it is. When it moves in left/up direction - everything is fine. When I disabled exit signal - tooltip is not blinking. So I assume it's calling exit and enter all the time when I move move down/right but... I don't really know why. Documentation says that signal is emitted when mosue enters shape - only once. And that's perfect. But why it emits exit signal when it's still in the shape? Unless it's different problem.
EXAMPLE