33 lines
700 B
GDScript
33 lines
700 B
GDScript
extends Area2D
|
|
|
|
var mouse_hovering = false
|
|
|
|
@export var tooltip_text : String
|
|
|
|
@onready var panel = $PanelContainer
|
|
|
|
func _ready():
|
|
$PanelContainer/Label.text = tooltip_text
|
|
|
|
func _process(delta):
|
|
if mouse_hovering:
|
|
panel.show()
|
|
if panel.global_position.x + panel.size.x > 384:
|
|
panel.global_position.x = 384-panel.size.x
|
|
if panel.global_position.x < 0:
|
|
panel.global_position.x = 0
|
|
|
|
if panel.global_position.y + panel.size.y > 256:
|
|
panel.global_position.y = 256-panel.size.y
|
|
if panel.global_position.y < 0:
|
|
panel.global_position.y = 0
|
|
else:
|
|
panel.hide()
|
|
|
|
func _on_mouse_entered() -> void:
|
|
mouse_hovering = true
|
|
|
|
|
|
func _on_mouse_exited() -> void:
|
|
mouse_hovering = false
|