Do Defold support touch in html5 build?


#1

Hi Everyone!

I am trying port my game with Defold and all of my prototype worked nice, but when I try run in HTML5 in my iPhone the touch does not work :frowning:

Someone know if I can use touch in HTML5 game on mobile?!

Thanks Advance


#2

Touch only works on native iOS and Android builds. We do not really recommend that you run the HTML5 export of your game on mobile. The HTML5 build is better suited for desktop browsers. On mobile we recommend the native builds for best possible performance.


#3

It is very good to know what @britzl said, and I can see what he is talking about when I run my HTML5 build on my mobile browser… :disappointed_relieved:

And what I did for playing it (my HTML5 build) on mobile, was simply to add a mouse click input event, because in a mobile browser the touch is detected as mouse click :wink:

Hope this helps


#4

Ah, yes, you are correct @Edgaronfo, the singe-touch event will be translated into a mouse click event which means that you can define a MOUSE_BUTTON _1/LEFT binding and detect that on HTML5 even on mobile. You will however not be able to detect multi touch.


#5

:wink::+1:


#6

I user Mouse Click and work fine :stuck_out_tongue:
I know the better solution is native app, but do you know about Instant Games?

I think it is cool to learn about.


#7

Any ideas how to catch multi touches in html5?
We finish making a game for instant games on facebook. But it turned out that the multi touches does not work. We need it to control the virtual gamepad and fire at one point.


#8

We actually don’t support multi touch on the HTML5 builds, but since you’re about to release a game on FB Instant Games it definitely is something we should prioritize. @Sven do you know what’s required for multi touch?


#9

A HTML5 native extension solution is also possible for the time being. Anyone could look into producing it and releasing it.


#10

I’m going to give this a shot soon.

Proof of concept works. It should be pretty easy to use this in your project to release the Instant Games html5 version with multitouch.


#11

it looks great, but when do you plan to release the native extension solution?


#12

I’ll work on it more today and maybe have something able to be used.


#13

I’m really close to having something usable but still dealing with a few issues as I’m not an expert with JavaScript. Can hopefully finish up next time I work on it which will be pretty soon and put out a 1.0 which will probably be replaced with a 2.0 soon after…

It seems like what I’m doing sometimes does and sometimes doesn’t interfere with normal click events so if you use what I make for multitouch on mobile you may not want to use built in input.


#14

we are looking forward to seeing your work. you are our hope and salvation.


#15

Please test this version on your devices and see if it works right (it only draws up to 4 dots in the demo)

https://www.pkeod.com/defold/mobile_multitouch/

It seems to work on Android but not on iOS for now, still working on issues and cleaning it up for release when I have time. You can look at the source there to see how it works as it’s not a native extension yet but has the JS code on the page.


#16

It is work on my phone, ios 11.3, safari


#17

I’ll still try to get them to work on my test devices. On iOS, it says multitouch is supported, but dots don’t show up and it crashes the webview after a while. The devices are kind of older now I’ll post more info on them in a bit.


#18

Hi @Pkeod , anything new? when will it be possible to use?


#19

The WIP is still here https://github.com/subsoap/touch I’ve not had time to figure out why it is crashing on older iOS devices yet so did not put the time into moving it past proof of concept into usable extension unfortunately. Anyone with time and older iOS device they can hook up for debugging and see why it’s crashing on mobile safari would be helpful.


#20

Hi @Pkeod
I had tried to use your example and found problem. it can’t transfer touch data to defold.

touch_data = json.decode(html5.run("get_touch_data()"))

This line always has return #touch_data =0
Could you help me, i don’t know js