Mouse Over Object - Text Boxes
#1
Posted 23 October 2008 - 04:17 AM
Help?
#2
Posted 23 October 2008 - 04:59 AM
Create:
show=falsemouse over:
show=truemouse exit:
show=falsedraw:
if show=true
{
draw_rectangle(mouse_x-100,mouse_y-20,mouse_x,mouse_y,false)
draw_set_color(c_white)
draw_text(mouse_x-98,mouse_y-1,"this is text")
}that is basically it.
#3
Posted 23 October 2008 - 05:41 AM
What if I wanted the box to show up when hovering over a moving object?
Edited by guitarman4545, 23 October 2008 - 05:49 AM.
#4
Posted 23 October 2008 - 01:40 PM
Doesnt work for me... hm :/
What if I wanted the box to show up when hovering over a moving object?
You have a few options: You can make the text a sprite, and draw the sprite when the mouse is over the object. Or you can make a box with text, like canc32 suggested. Instead of using the "mouse enter" and "mouse leave" events, and using a variable just use the following code in the object that you want the text box for, in the draw event:
if (distance_to_point(mouse_x,mouse_y) == 0)
{
draw_set_color(c_black);
draw_rectangle_color(mouse_x-64,mouse_y-48,mouse_x+56,mouse_y+48,c_ltgray,c_ltgray,c_ltgra
y,c_ltgray,false);
draw_rectangle(mouse_x-64,mouse_y-48,mouse_x+56,mouse_y+48,true);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(mouse_x,mouse_y,"Text goes here.");
}The important part is the "distance to point" because this returns the distance from the OUTSIDE EDGE of you object to the mouse position. The rest of the code is just drawing the box, centering the text, etc. Also, you probably know this, but if you put things in the draw event, it will not draw a sprite anymore. So draw the sprite yourself, in the draw event. "draw_sprite()" or "draw_sprite_ext()" should do it, just make sure you draw it before you draw the box code above, or the sprite will be on top of the box. Ok, hope that helps, and good luck.
#5
Posted 23 October 2008 - 08:54 PM
Btw sycosquirl, I tried that and says I needed Pro. Thanks for the help, but I dont have Pro quiet yet.
Edited by guitarman4545, 23 October 2008 - 10:06 PM.
#6
Posted 25 October 2008 - 07:43 PM
Let me restate my question. I need to be able to click a moving object, and a text box will pop up in a defined position everytime. (Not relative to the object) Any ideas?
#7
Posted 25 October 2008 - 07:45 PM
Edited by Mnementh, 25 October 2008 - 07:45 PM.
#8
Posted 31 March 2010 - 07:22 AM
Doesnt work for me... hm :/
What if I wanted the box to show up when hovering over a moving object?
You have a few options: You can make the text a sprite, and draw the sprite when the mouse is over the object. Or you can make a box with text, like canc32 suggested. Instead of using the "mouse enter" and "mouse leave" events, and using a variable just use the following code in the object that you want the text box for, in the draw event:if (distance_to_point(mouse_x,mouse_y) == 0) { draw_set_color(c_black); draw_rectangle_color(mouse_x-64,mouse_y-48,mouse_x+56,mouse_y+48,c_ltgray,c_ltgray,c_ltgra y,c_ltgray,false); draw_rectangle(mouse_x-64,mouse_y-48,mouse_x+56,mouse_y+48,true); draw_set_halign(fa_center); draw_set_valign(fa_middle); draw_text(mouse_x,mouse_y,"Text goes here."); }
The important part is the "distance to point" because this returns the distance from the OUTSIDE EDGE of you object to the mouse position. The rest of the code is just drawing the box, centering the text, etc. Also, you probably know this, but if you put things in the draw event, it will not draw a sprite anymore. So draw the sprite yourself, in the draw event. "draw_sprite()" or "draw_sprite_ext()" should do it, just make sure you draw it before you draw the box code above, or the sprite will be on top of the box. Ok, hope that helps, and good luck.
distance_to_point() is really great when dealing with moving objects. Thanks for this, Syco.
#9
Posted 03 February 2012 - 10:30 PM
it is vary simple:
Create:show=falsemouse over:show=truemouse exit:show=falsedraw:if show=true { draw_rectangle(mouse_x-100,mouse_y-20,mouse_x,mouse_y,false) draw_set_color(c_white) draw_text(mouse_x-98,mouse_y-1,"this is text") }that is basically it.
i tried to make. that when enter pointer on object a textbox appears.
but when i wrote those commands on object_A. i dont see the object_A
but if i enter on them, message appears.
what i'm doing wrong?
#10
Posted 03 February 2012 - 10:32 PM
#11
Posted 04 February 2012 - 09:25 AM
at position 1: Unknown function or script: draw_selfMake sure to remember to use draw_self() so that your object does not disappear.
tried to write that code in create event and draw event (before "if show=true...." command
EDIT:info from wiki about draw_self "This function is a new function in Game Maker 8.1. "
so i guess, i go and try to update my game maker
EDIT2: tried with 8.1. it works now.
THANKS!
Edited by vidokas, 04 February 2012 - 09:44 AM.
#12
Posted 04 February 2012 - 05:33 PM
#13
Posted 20 July 2012 - 05:07 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











