Jump to content


Photo

Text doesnt work on HUD


  • Please log in to reply
19 replies to this topic

#1 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 05 July 2012 - 04:23 PM

Hey there.
I've just started with GameMaker and made a little game. I've made my HUD and i want that a little information comes up when you hold the mouse over an icon.
My problem is that it doesnt work when i place the text object in the HUD, only if i place it on the map. Is there anyone who could explain what im doing wrong? :)

Code:
Create:
text=""

Mouse Enter:
text="Attack Damage"

Mouse Leave:
text=""

Draw:
draw_sprite(invisible_wall_sprite,0,x,y)
draw_set_color(c_white)
draw_text(mouse_x-30,mouse_y-60,text)

Pictures:
Posted Image
Posted Image

Thanks in advance :)
  • 0

#2 ChefDavid22

ChefDavid22

    No, YOU shut up!

  • GMC Member
  • 1193 posts
  • Version:GM:Studio

Posted 05 July 2012 - 04:25 PM

For the HUD change the DRAW to a DRAW GUI event.

Also make sure the depth of the HUD object is in front of everything else. It could very well being drawing the text but it shows up behind an object.
  • 0

#3 Turtle1

Turtle1

    GMC Member

  • New Member
  • 68 posts

Posted 05 July 2012 - 04:30 PM

Hey there.
I've just started with GameMaker and made a little game. I've made my HUD and i want that a little information comes up when you hold the mouse over an icon.
My problem is that it doesnt work when i place the text object in the HUD, only if i place it on the map. Is there anyone who could explain what im doing wrong? :)

Code:

Create:
text=""

Mouse Enter:
text="Attack Damage"

Mouse Leave:
text=""

Draw:
draw_sprite(invisible_wall_sprite,0,x,y)
draw_set_color(c_white)
draw_text(mouse_x-30,mouse_y-60,text)

Pictures:
Posted Image
Posted Image

Thanks in advance :)



for some reason, i can't see your pictures, but it could be because of the color of the text, or that the hud is placed in front of it(check the depth of hte hud)

other then that, unless these darn pictures load... i can't help you.
  • 0

#4 Southman

Southman

    I simply am not here

  • GMC Member
  • 1662 posts
  • Version:GM:Studio

Posted 05 July 2012 - 04:32 PM

For the HUD change the DRAW to a DRAW GUI event.

Also make sure the depth of the HUD object is in front of everything else. It could very well being drawing the text but it shows up behind an object.


He's not using Studio.

Just make the depth something like "-100000000". Lower depths draw in front of higher depths.
  • 0

#5 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 05 July 2012 - 04:38 PM

Now you are talking about depth, so i guess i've made my hud in a wrong way, as i have made it at the same picture as my map. Its the whole thing that are my background and i just used views to tell where the HUD is and where the map is..
Does it gives any sense? :/
Or can i change the depth on different views? :/

EDIT: Tried to change the depth of the object, it didnt work either..
  • 0

#6 ChefDavid22

ChefDavid22

    No, YOU shut up!

  • GMC Member
  • 1193 posts
  • Version:GM:Studio

Posted 05 July 2012 - 04:44 PM

Did you do as I suggest and change the draw to draw gui?

The depth is set in the object itself

Think of depth like this
0 is where everything starts
negative number moves it towards you
possitive number moves it away from you

Edited by ChefDavid22, 05 July 2012 - 04:45 PM.

  • 0

#7 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 05 July 2012 - 04:50 PM

Did you do as I suggest and change the draw to draw gui?

The depth is set in the object itself

Think of depth like this
0 is where everything starts
negative number moves it towards you
possitive number moves it away from you


I aint using Studio, so i cant use the Draw GUI as far as i know.
I've tried to change the depth of the object several times, but i doesnt work :/
  • 0

#8 ChefDavid22

ChefDavid22

    No, YOU shut up!

  • GMC Member
  • 1193 posts
  • Version:GM:Studio

Posted 05 July 2012 - 05:03 PM

Ah right, I saw that above just forgot.

The only reason why it would not be working based on your description is a depth issue.

Are both these objects called the same thing?

Go to the area of the room where it works - then hover over the hud object. Do you see the text printing on the object in the room instead?

Do some testing by changing the coordinates of where it writes itself. room_width/2,room_height/2 for starters to see if you can get it to show up in the center view.

Edited by ChefDavid22, 05 July 2012 - 05:13 PM.

  • 0

#9 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 05 July 2012 - 05:06 PM

have you tried to put the mouse enter in the draw event??
Nevermind, Wasn't thinking......

Edited by Merlocker, 05 July 2012 - 05:07 PM.

  • 0

#10 Southman

Southman

    I simply am not here

  • GMC Member
  • 1662 posts
  • Version:GM:Studio

Posted 05 July 2012 - 05:28 PM

I have a feeling it has to do with the multiple views.
Why are you using more than one view?
  • 0

#11 ChefDavid22

ChefDavid22

    No, YOU shut up!

  • GMC Member
  • 1193 posts
  • Version:GM:Studio

Posted 05 July 2012 - 05:29 PM

I have a feeling it has to do with the multiple views.
Why are you using more than one view?


I was thinking that too. My thought was the text is showing up - but showing up in another area because the the view. I had that happen to me once. I had to caluclate how much my view moved before I could see it.
  • 0

#12 Southman

Southman

    I simply am not here

  • GMC Member
  • 1662 posts
  • Version:GM:Studio

Posted 05 July 2012 - 05:47 PM

Didn't test it, but try something like

draw_text(view_xview[2]+window_mouse_get_x()-30,view_yview[2]+window_mouse_get_y()-60,text)

  • -1

#13 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 05 July 2012 - 08:12 PM

I use 2 views, because it was the only way i could think of, that would work, without too much work. Also i saw different tutorials on Youtube, and the best one did it with views :/
And it doesnt show any text when i hover over in the Room, not on any of them :/

Didn't test it, but try something like

draw_text(view_xview[2]+window_mouse_get_x()-
30,view_yview[2]+window_mouse_get_y()-60,text)


Just tried it out and it didnt really seem like it was working :/

Edited by mrjolle, 06 July 2012 - 09:16 AM.

  • 0

#14 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14385 posts
  • Version:GM:Studio

Posted 06 July 2012 - 04:45 AM

Do you have an actual object in your hud that will capture the mouse enter event? Looks like your code is in the object you are dragging
  • 0

#15 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 06 July 2012 - 09:18 AM

Do you have an actual object in your hud that will capture the mouse enter event? Looks like your code is in the object you are dragging

Ehm i'm not really sure about what you mean :/
  • 0

#16 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 06 July 2012 - 02:55 PM

He'ssaying is the axe in the HUD an object or is it just a sprite. And that the object that is draggable has your text code.
  • 0

#17 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 06 July 2012 - 07:58 PM

He'ssaying is the axe in the HUD an object or is it just a sprite. And that the object that is draggable has your text code.

Maybe thats the reason. The Axe is directly drawn on the HUD and not a sprite/object, but i thought i could place my invisible object on the axe and then it would work :/
  • 0

#18 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14385 posts
  • Version:GM:Studio

Posted 06 July 2012 - 08:06 PM

Yes Make a stub hud object with the same sprite, same code. Your hud items/icons should be real objects, it makes it easier to code.
  • 0

#19 mrjolle

mrjolle

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 08 July 2012 - 08:27 AM

Yes Make a stub hud object with the same sprite, same code. Your hud items/icons should be real objects, it makes it easier to code.

Just to be sure i understood correct :) Want me to make the HUD background as one sprite/object, and then all the icons as other sprites/objects and them place them on each other? Or is it only the icons you want me to make sprites/objects? :)
  • 0

#20 Southman

Southman

    I simply am not here

  • GMC Member
  • 1662 posts
  • Version:GM:Studio

Posted 08 July 2012 - 04:40 PM

Yes. In your HUD object, set the depth really low, and draw the HUD sprite at view_xview+whatever and view_yview+whatever, then in each of the icons objects, set their depth to the HUD's depth-1. Then in the end step for each of the objects, move them to their relative places on the HUD.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users