Using a script and a GUI, i manage to create a popup text on mouse over hotspot.
the code :
function repeatedly_execute_always()
{
if (IsInterfaceEnabled()) {
gMouseOver.X = mouse.x + 5; // setting the padding (10)
gMouseOver.Y = mouse.y - 20; // setting the padding (10)
gMouseOver.Visible = true;
} else gMouseOver.Visible = false;
}
That should put the GUI popup in the top right of the mouse cursor.
but my problem occurred when the mouse hovering a hotspot near the right edge of the screen, the popup gui will pop out of the camera. What i need is for the gui to able to track if its out of view, e.g move it to the top left of the mouse cursor.
Is this possible to do by adding some more codes?
Sure. Just let the game check, if the width of your GUI is bigger than mouse.x-Screenwidth.
if yes, let the GUI popup at GUI.x = mouse.x - GUI_width.
I think that could work ^^
Quote from: Kumpel on Tue 27/10/2015 17:25:48
Sure. Just let the game check, if the width of your GUI is bigger than mouse.x-Screenwidth.
if yes, let the GUI popup at GUI.x = mouse.x - GUI_width.
I think that could work ^^
Thank you @Kumpel i will try that, so, should i slip that if statement on the same function i've made? or made another statement?
Ive tried this :
function repeatedly_execute_always()
{
if (IsInterfaceEnabled())
{
gMouseOver.X = mouse.x + 5; // add your own number here (10)
gMouseOver.Y = mouse.y - 20; // add your own number here (10)
gMouseOver.Visible = true;
}
else if (gMouseOver.Width >= mouse.y + 640)
{
gMouseOver.X = mouse.x - 5; // add your own number here (10)
gMouseOver.Y = mouse.y + 20; // add your own number here (10)
gMouseOver.Visible = true;
}
else gMouseOver.Visible = false;
But no luck..
(sorry, a little bit behind in code understanding)
Think you need to add it inside your if (IsInterfaceEnabled()) , not as an else if
Something like this:
if (IsInterfaceEnabled())
if (gMouseOver.Width >= mouse.y + 640)
// put code for the left display
else
// put code for the right display.
(not exact code, but more intended as an explanation). :)
EDIT: Reason your code doesn't work, is that as soon as IsInterfaceEnabled is true, it won't run the else if code. Ever.
Quote from: Cassiebsg on Tue 27/10/2015 18:03:14
Think you need to add it inside your if (IsInterfaceEnabled()) , not as an else if
Thank you so much Cassie! now i know that i can put another if / else inside an if / else ... (laugh) i hope it'll works properly as intended!
Edit :
Done, Rather than using room width, I changed the limitation using the right edge border. Thank you again!
function repeatedly_execute_always()
{
if (IsInterfaceEnabled())
{
if (GetViewportX() + mouse.x >= Room.RightEdge)
{
gMouseOver.X = mouse.x - 110; // Make this right human!
gMouseOver.Y = mouse.y - 22; // And this too!
gMouseOver.Visible = true;
}
else
gMouseOver.X = mouse.x + 7; // Make this right human!
gMouseOver.Y = mouse.y - 22; // And this too!
gMouseOver.Visible = true;
}
else gMouseOver.Visible = false;
}