Hi there,
I am trying to make a tooltip for Node2D elements displayed in my 2D game.
My game tree looks like this:
Viewport (root)
---- Main map (a Node2D)
-------- Camera2D
-------- Tilemap
-------- Sprite
------------- tooltip ( a Control )
----------------- Label
I manage to have the tooltip displayed at the right place when the mouse is around the sprite. (nice!)
But the tooltip gets scaled with the camera, resulting in unreadable text when I zoom out.
I would like the size of the tooltip to stay constant, ie not scaling with its parent sprite. Is there a simple way to do that ?
By the way, here is the code of my tooltip control:
public class MyToolTip : Control
{
Label _child;
public MyToolTip(string txt)
{
_child = new Label();
_child.Text = txt;
this.AddChild(_child);
this.Connect("mouse_entered", this, nameof(OnMouseEntered));
this.Connect("mouse_exited", this, nameof(OnMouseExit));
this.RectMinSize = new Vector2(16, 16);
this.RectPosition = -this.RectMinSize / 2;
_child.RectPosition = new Vector2(30, 30);
_child.Visible = false;
// Not setting "this.Visible = false;"
// That would prevent getting the next "mouse_entered" messages
this.Visible = true;
}
void OnMouseEntered()
{
_child.Visible = true;
}
void OnMouseExit()
{
_child.Visible = false;
}
}