• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows {{Fixed}} Text does not draw

B

Bokkie2988

Guest
Hello,

I have code for when the player is destroyed, a text appears with Game Over, but it doesn't work, nothing happens. This is my code:
Code:
if (!instance_exists(o_player)){
    draw_text_colour(x, y, "Game Over", c_white, c_white, c_white, c_white, 1);
}
(This is in a different object then the player)

Can anyone help?

-Bokkie
 

samspade

Member
Hello,

I have code for when the player is destroyed, a text appears with Game Over, but it doesn't work, nothing happens. This is my code:
Code:
if (!instance_exists(o_player)){
    draw_text_colour(x, y, "Game Over", c_white, c_white, c_white, c_white, 1);
}
(This is in a different object then the player)

Can anyone help?

-Bokkie
The code itself is correct - e.g. no errors that I see - so that means the problem is somewhere else. Possible issues with something like this could include:
  • o_player still exists somehow
  • this object doesn't exist
  • it's x and y aren't where you think they are
  • something is off with other drawing text variables (such as halign or valign)
  • it's not on the right layer (GMS2) or depth (GMS1) - e.g. it is behind something
  • something is off with your font (e.g. it doesn't include those characters)
If you're comfortable with the debugger, I would put a break point in the code and see if it hits it, and if it does then check all the variables and see what is happening. Otherwise, I would use some show_debug_messages to check things like whether the code is being run and what the x and y are. You might also want to try specifically declaring a couple of the font related variables like halign, valign, and font.
 
B

Bokkie2988

Guest
The code itself is correct - e.g. no errors that I see - so that means the problem is somewhere else. Possible issues with something like this could include:
  • o_player still exists somehow
  • this object doesn't exist
  • it's x and y aren't where you think they are
  • something is off with other drawing text variables (such as halign or valign)
  • it's not on the right layer (GMS2) or depth (GMS1) - e.g. it is behind something
  • something is off with your font (e.g. it doesn't include those characters)
If you're comfortable with the debugger, I would put a break point in the code and see if it hits it, and if it does then check all the variables and see what is happening. Otherwise, I would use some show_debug_messages to check things like whether the code is being run and what the x and y are. You might also want to try specifically declaring a couple of the font related variables like halign, valign, and font.
I will try some things, do you (or someone else) know how to draw the text in the middle of the screen? Now I've just guessed where it might be.
 

samspade

Member
I will try some things, do you (or someone else) know how to draw the text in the middle of the screen? Now I've just guessed where it might be.
Frosty's list is better than mine so I would use his. But the short answer to this question is it depends on how you are drawing it. Are you drawing it in a draw event or gui event? Do you have cameras or views?
 
B

Bokkie2988

Guest
Frosty's list is better than mine so I would use his. But the short answer to this question is it depends on how you are drawing it. Are you drawing it in a draw event or gui event? Do you have cameras or views?
I've fixed the problem by creating a different object which is created to draw the text. I guessed my other code interfered with drawing the text.
Thanks guys!

-Bokkie
 
Top