0 votes

Hi everyone,

I have built a little self-made button (Area2D – CollisionShape2D) including a couple of functions, animations, a timer etc. which all show their "print" in the output. And these work fine when clicking with the mouse, but when thouching the button on a touchscreen some of those "prints" come multiple times, at least twice, sometimes four times...

I can't quite make out why that happens. Any suggestions?

By the way: testing on a phone obviously doesn't let me see the output in the editor. Is there a way of displaying that output directly in the running program, like in a text-field? Because I have the feeling that the issue might not appear on all touch-devices generally.

in Engine by (304 points)

Why not just use a TouchScreenButton node?

Hi rahsut,

I tried a TouchScreenButton, to no avail.
It occurs with mouse-clicks as well when I turn on "Emulate Touch From Mouse", so I feel like it's probably not a device-issue but indeed my code... I'll see what I can find out, I just wondered if that might be a known phenomenon in some cases.

Try calibrating your touch screen. That might help. I have a touchscreen laptop and for me, the touch screen buttons work. Though for me, I'm not printing anything but instead adding a value to my players x value. If calibrating the touch screen still doesn't fix anything, try using a Button node. That way, you can tell if it's your code or something else. Also, share some of the code that does the printing. That might help me (and others) better help you .

After testing on my touchscreen with an input pen as well, which turned out even more chaotic (triggering three times every now and then...), I'm quite sure it's not a code-problem.
But I solved the problem with set_pickable:

if Input.is_action_just_pressed("mousebuttonclick"):
    print ("Tapped! Timer started!") # <-- THIS WAS PRINTED 2 TIMES
    get_node("SpriteButtonArea").set_pickable(false)
    get_node("SpriteButtonAnimationPlayer").play("small")
    yield (get_node("SpriteButtonAnimationPlayer"), "animation_finished")
    get_node("SpriteButtonArea").set_pickable(true)

I already did this with all other animations, but for some reason I thought I wouldn't need to with the extremely short "small" (0.001 sec)... duration obviously doesn't matter here!

Thanks for your thoughts!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.