This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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 (525 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!

You can display print messages for an android game by:
(I'm assuming you've already set up Godot so it can export games to Android. If not, watch a guide on Youtube or read Godot docs.)

  • click Debug at the top of Godot's window and make sure "Deploy with remote debug" is checked on.
  • connect your phone to your computer with USB
  • an Android button should appear next to the play scene button, stop scene button, etc. click it to test your game on your phone.
  • output should now print messages on your computer while playing your game on your phone. Yay!

P.S. I'd upload a screenshot but I can't, and last time I tried setting up imgur, it didn't work...?

I indeed never checked "remote debug" before and now that I did I wonder why... thanks for the extremely useful hint!

Np yeah it's pretty helpful.

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 Frequently asked questions and 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 [email protected] with your username.