• 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!

Draw Text/Variable not working

B

BlueDuckYT

Guest
I am using DnD in version 1.4. When I try to use a draw variable value or draw text nothing appears. I even tried using a change font block. What is going wrong here?
 
B

BlueDuckYT

Guest
The code does not work. I am not getting any errors, but the text is not showing up.
 

Tornado

Member
is your background black? in this case you won't see the black text. if yes, try to change text color:
draw_set_color(c_yellow);

Do you have a sprite on this object? if yes, is the sprite shown?

edit: check the coordinate for text. is it within visible part of the room? try first with smaller values like 100,100.
 
Last edited:

Ladi_Pix3l

Member
Code:
draw_text(0,0,"" + string(variable));
Try that captain


EDIT: You need the "+" when adding information in draw_text();

Example:
Code:
draw_text(320,240,"Ammo: " + string(player.ammo) + "/" + string(player.ammoMax));
 
Last edited:
B

BlueDuckYT

Guest
is your background black? in this case you won't see the black text. if yes, try to change text color:
draw_set_color(c_yellow);

Do you have a sprite on this object? if yes, is the sprite shown?

edit: check the coordinate for text. is it within visible part of the room? try first with smaller values like 100,100.
Coords are good, sprite is visible. Still not there.

Code:
draw_text(0,0,"" + string(variable));
Try that captain


EDIT: You need the "+" when adding information in draw_text();

Example:
Code:
draw_text(320,240,"Ammo: " + string(player.ammo) + "/" + string(player.ammoMax));
is the phrase string needed? I don't want any string there, as I have the object for the icon next to the name.
 
B

BlueDuckYT

Guest
It worked, but now the Sprite is gone...
Also, how do I define a variable without resetting it every time I switch rooms?
 

Tornado

Member
when you explicitly define draw event, then sprite won't be drawn automatically anymore. put this as first line in that draw event:
draw_self(); // this draws the sprite

and after that your draw_text(something)
 
Last edited:

Tornado

Member
....
Also, how do I define a variable without resetting it every time I switch rooms?
define some controller object in one room and make that object persistent in object editor. that way object will not be destroyed, but will be present in every room.
This controller object contains then your variables.

Or just define some global variables like
global.pointsForWin = 5;
global variables you can access from everywhere.
 
Top