|
|
|
|
Reply From: |
wombatstampede |
So for your question first:
No (as far as I know).
A touch on TextureButton
generates a pressed() signal but only because of the Touchscreen-Mouse emulation. (If it is enabled in the projects preferences which it is by default.) This Mouse emulation is not multitouch capable. (At least it wasn’t the last time, I checked it)
However: You should be able to receive the InputEventScreenTouch
Event via the _gui_input()
handler. This event has a member pressed
which indicates if the area of the control was pressed or released. And it has an index
which can be used track different parallel touch events (i.e. when dragging).
Also, there’s the TouchScreenButton:
Be aware:
If you have emulations (touch->mouse or mouse->touch) enabled you might receive multiple events on one control at once. (Mouse and Touch)
Finally, there are some touch demos.
https://godotengine.org/asset-library/asset?category=&support[official]=1&godot_version=&sort=updated&filter=touch
I didn’t know that there is a TouchScreenButton Node haha. I’ll give that one a try first.
What do you mean by emulations is enabled? Is it the one in the project settings, the Emulate Touchscreen - On/Off?
Thanks for this man.
Edit: Hi, I’ve used _gui_input()
as input handler instead of the pressed()
signal, just like what you’ve said and now I am able to do multitouch, Thanks but I have another problem though. Multitouch is working and the functions of each pressed can be read but the texture of the buttons doesn’t change. The pressed texture is only working on the first button I’ve pressed, while the other buttons stays normal. (The function for each pressed is still working though)
mr-ro95 | 2019-03-03 23:57
Did you try setting the buttons pressed
attribute when receiving InputEventScreenTouch? (according to pressed state)
BaseButton — Godot Engine (latest) documentation in English
Doing it that way maybe can be problematic. I’d see probable problems when a touch is released outside the button. (Finger pressed on button, dragged outside, and then released.) You’ve got to try this out.
In worst case you’d also have to save the touchevent index for each button on press and watch _input() (which is a global event handler) for pressed=false events with that very index.
Yes, with “Emulations” I’m writing of the project settings->input devices->Pointing.
Emulate Touch from Mouse:
→ Create “fake” Touch events from the Mouse Events. So you can roughly test touch event handling on non-touch devices (on PCs).
Emulate Mouse From Touch:
→ Creates “fake” Mouse events from Touch Events. This enables Mouse-like behaviour on touch-screen devices. But: This emulation is not multi-touch capable. (As far as I know)
Keep in mind:
There’s a possibility of mouse events on Mobile Touch-Devices. At least on android devices you can actually attach mice via usb (USB-OTG) or bluetooth.
wombatstampede | 2019-03-04 07:22
Yes, I’ve tried changing to pressed state, but still doesn’t work the click->drag-> release thing doesn’t happen though, well I’ve made it happen once, I don’t know why I can’t reproduce it.
This TextureButton is so weird for multitouch hahaha. The function during the pressed state are working fine, but the texture_pressed state is not working.
mr-ro95 | 2019-03-04 23:11
Ok, I tried around (only on PC using “Emulate Touch Events via Mouse” emulation).
I checked the BaseButton “ToggleMode”
I unchecked ButtonMask (Mouse left), so no Mouse Events trigger the button.
Then I attached this script to the TextureButton:
extends TextureButton
func _gui_input(event):
if event is InputEventScreenTouch:
pressed = !pressed
print ("pressed: "+str(event.pressed))
Hope this works also on Touch Devices.
wombatstampede | 2019-03-05 07:36