Jump to content


Photo

Help with code that works in GM, but not HTML5


  • Please log in to reply
5 replies to this topic

#1 lumavr

lumavr

    GMC Member

  • New Member
  • 8 posts

Posted 16 October 2011 - 03:01 AM

I have two pieces of code I need help with. They work fine running in regular GameMaker, but not in HTML5. There might be a different way of writing the code that works. I am working on a typing game. Thanks for any help.


This should draw the text on the screen that the user types, but nothing shows on the screen in HTML5.

draw_text(view_xview[0]+110,view_yview[0]-3,"#"+keyboard_string);


This should destroy the object on the screen by typing the word with the object but nothing happens and it could be related to the first problem:

if(keyboard_string==targetID2.word) //if the currently-typed text is the same as the word (word is fully typed)
{

with(targetID2){instance_destroy(); // destroy the object
}
  • 0

#2 epicCreations

epicCreations

    Cool As Ace

  • New Member
  • 1241 posts

Posted 16 October 2011 - 03:34 AM

keyboard_string apparently doesn't work at all in GM HTML5 as of now
  • 0

#3 Joe H

Joe H

    GMC Member

  • GMC Member
  • 352 posts
  • Version:Unknown

Posted 16 October 2011 - 05:03 PM

Don't forget to clear the keyboard string before checking for a specific word. Otherwise you will always have an arbitrary string of characters. This is from the help: "String contains the last at most 1024 characters typed."


I believe you use the following to clear the keyboard string:

keyboard_string = ""

Essentially you are setting the keyboard_string to nothing. Then as the player types they are adding key presses to the string.
  • 0

#4 lumavr

lumavr

    GMC Member

  • New Member
  • 8 posts

Posted 18 October 2011 - 10:41 PM

keyboard_string apparently doesn't work at all in GM HTML5 as of now


Does anyone have an alternative to keyboard_string that would work for what I need it to do?
  • 0

#5 OMGCarlos

OMGCarlos

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:HTML5

Posted 19 October 2011 - 01:02 PM

I created this script a week or two ago:

Spoiler

The page is down for maintenance, but you can read how to use it in this post: http://gmc.yoyogames...0

Edited by OMGCarlos, 19 October 2011 - 01:06 PM.

  • 0

#6

  • Guests

Posted 19 October 2011 - 03:35 PM

This is fixed in the next release... (we hope today!)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users