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

HTML5 HTML5 draw_text_transformed not working

C

Cheezeh3d

Guest
Hello people.

So I have been working on a school project for a while and I hit a snag with HTML5 that I can't seem to fix. I have a login screen with simple homemade text boxes, but to type in the text box you need to click on it. I've troubleshooted a lot, so I know this is the issue.

I have it set so when the mouse enters the text box, it sets a variable called email_hover to equal true. Then, in the step event below, it checks if mb_left was pressed. If that happens, then it will deactivate the other text box I have on the screen, activate the current text box, and set the keyboard_string to equal a variable called email_text which will then draw the text in a draw event on top of the text box (this part isn't shown here). Here is the code for my mouse.
Code:
if(email_hover == true){
    if(mouse_check_button_pressed(mb_left)){
        obj_password_text_box.password_selected = false;
        email_selected = true;
        keyboard_string = email_text;
    }
}
I did some troubleshooting and found that it tracks the mouse entering the text box because email_hover will equal true, but it won't track that mb_left is being pressed. This all works with a windows and mac build, but I can't get it to work when I build to html5. I did some research and I couldn't find anyone else having this issue. I thought about changing the code to something a little more complicated, but I really don't want to do that if I don't have to. Any thoughts?
 

chmod777

Member
Hi,

I've tried using the last stable version and I really see no issue with mouse_check_button_pressed (even when the canvas is scaled).
If you replace...
Code:
if(mouse_check_button_pressed(mb_left)){
with just:
Code:
if(true){
does the code inside the condition work?

Also, is there a single instance of "obj_password_text_box" in the room?
 
C

Cheezeh3d

Guest
Hi,

I've tried using the last stable version and I really see no issue with mouse_check_button_pressed (even when the canvas is scaled).
If you replace...
Code:
if(mouse_check_button_pressed(mb_left)){
with just:
Code:
if(true){
does the code inside the condition work?

Also, is there a single instance of "obj_password_text_box" in the room?
Actually, I missed a step and found that the mouse check function is working. Now, it seems that it won't actually draw the text. Here's what I got.
Code:
draw_sprite(sprite_index,0,x,y)
draw_set_halign(fa_center);//set text alignment
draw_set_color(c_black);//set text color
draw_text_transformed(x, y+110, string(email_text), 2.5, 2.5, 0);//draw text
Here, it draws the textbox sprite, sets the alignment and color of the text, and then draws the text inside of the text box. email_text is the keyboard_string. Again, this all worked with a windows build. So maybe the draw_text_transformed is the issue? Idk.
 

chmod777

Member
So maybe the draw_text_transformed is the issue? Idk.
Maybe... Try just using draw_text and see if it works like this.
Also, if you're not using a recent version and if you have no font defined (sprite font or from the resource tree), you'll have to add one.
 
C

Cheezeh3d

Guest
Maybe... Try just using draw_text and see if it works like this.
Also, if you're not using a recent version and if you have no font defined (sprite font or from the resource tree), you'll have to add one.
I figured it out actually. Apparently html doesn’t automatically define fonts, so a I had to create a basic font and define it in my draw event. Thanks for the help! Wouldn’t have figured that out without it.
 
Top