Do Defold support touch in html5 build? (SOLVED)

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

6 Likes

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.

5 Likes

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

4 Likes

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.

7 Likes

It is work on my phone, ios 11.3, safari

7 Likes

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.

2 Likes

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

2 Likes

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.

5 Likes

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

Are you testing on a device which supports multitouch / in chrome with multitouch simulator active?

Does the above link work on your device? https://www.pkeod.com/defold/mobile_multitouch/

It will not work in vanilla chrome or defold as there is no fallback for normal touch/click in the example atm.

I tested In safari, ios 11, iphone 6s.
It count all touches, but position of orbs do not work.

The linked version doesn’t work or the copy downloaded from github doesn’t work?

This is older version of github project with some different changes, I believe it’s the version from that link.

https://www.pkeod.com/defold/touch/ has updated version.

I only have older iOS devices so unfortunately I probably can’t help with this. Someone else will need to. It’s also possible the reason it’s not working well on iOS is because it interferes with what Defold is using to get touch. I’m not sure. It would be better at this point to wait until Defold team can add multitouch support for html5 in and test as they probably have access to more devices.

1 Like

It seems to me, that parsing json in every update at 60 fps, then using it to control the virtual joystick in an Instant game is very quick & dirty hack.
@britzl, @Oleg_The_Evangelist guys from Defold, we need your help, or do you think this is good solution for multi-touch html5 instant games?
Lua:

function update(self, dt)
	local touch_data = json.decode(html5.run("get_touch_data()"))

Js:

function get_touch_data() {
	return JSON.stringify(touch_data);

Do you have an alternative control scheme when playing on desktop?

Yes, we have keyboard for movement and mouse for firing on desktop. On mobile we need to use virtual joystick (first touch) and second touch for firing.

This is obviously not optimal, but it’s on the other hand not the end of the world either. Since it’s done only once per frame I guess it will not have a really severe impact on performance. But it is a call from engine to JS which I’m guessing isn’t going to be super fast. And json.decode is pretty fast, so all in all you should be ok with this solution.

1 Like

Is there an ETA on when we might have multi-touch support for HTML5 builds?

1 Like

We’ve had it in the two most recent sprints but decided to push it ahead of us in favour of modularising the engine further. During this sprint we’ll move iap.* and iac.* to native extensions which should conclude the work for now. My guess would be that we tackle multi-touch in 1.2.164, but I can’t make a promise (we really want to do it though!).

5 Likes

I really want you to do it too! It would be super-helpful to me, at least.

4 Likes

Solved in 1.2.164

3 Likes