Jump to content

Text-input


Mattias
 Share

Recommended Posts

Oh, so I can add normal html elements into the game? Is there an example on how to do this?

The places these will go will be when you enter your name to save it to highscore, and the other state it will be used in is a "share" screen. Name + email.

 

I'll experiment some and see how it goes.

 

Edit: Just saw Cudabear's answer. I will most likely do that. Right now trying to find the scaling variable to set the correct size and position for the input, since I have a input background in the game already.

Link to comment
Share on other sites

I tried adding an input on top of the canvas with jquery, but no matter which z-index I use I can't get it on top of the canvas.

Is there something more I need to do? I use position absolute to position it.

 

edit: now for some reason it works, at least in chromium. Maybe I had some cache causing it somewhere

Link to comment
Share on other sites

Thanks for the help, I managed to get the scale of the scene from the Input class and now I just need to keep updating the input positions in case the screen changes.

I also got the margin-left from the canvas style since I append the inputs to body. and then I use that leftOffset to get it to the correct position.

I think I got this to work, haven't actually tried fetching data from them yet but I don't think that would be a problem at all :)

Link to comment
Share on other sites

  • 1 year later...
Obviously Rich's answer is the best solution, but alternatively if you need a form in the own game you could make a "fake form".
In a recent project I needed a form to match an user code inside a state of the game and we can't use a HTML form so I made this fake form:
 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...