# Virtual game pad example

**URL:** <https://forum.defold.com/t/virtual-game-pad-example/33335>\
**Category:** Questions\
**Created:** [October 30, 2018, 8:52pm UTC](https://forum.defold.com/t/virtual-game-pad-example/33335 "2018-10-30T20:52:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [October 30, 2018, 8:52pm UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/1 "2018-10-30T20:52:13Z")

</div>

I have a question about virtual game pad from @britzl public examples: why (on the build on Android) when the touch is released, the joystick don’t get back to the center? On Windows it works like that. How can I debug it?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 31, 2018, 5:24am UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/2 "2018-10-31T05:24:57Z")

</div>

Hm, not sure, but it seems like this piece of code isn’t running as expected:

> <https://github.com/britzl/publicexamples/blob/master/examples/virtual_gamepad/virtual_gamepad/virtual_gamepad.gui_script#L36-L40>

I’d add some print statements or set a breakpoint and inspect the state when `touch.released` is true.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [October 31, 2018, 6:32am UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/3 "2018-10-31T06:32:24Z")

</div>

I also suspected touch.released. Though, I haven’t any idea on how can I debug it on mobile. Do you use some logs or is there more convenient way? I mean debugging apk’s not builds on a remote dmengine. The joystick goes back to the center when I touch on “A” button only.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 31, 2018, 8:36am UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/4 "2018-10-31T08:36:10Z")

</div>

You can either use `print("Hello")`from your code, and watch it in your terminal window using [adb logcat](https://developer.android.com/studio/command-line/adb).

Edit: Here’s a handy tool for this: [android\_deploy.sh](https://forum.defold.com/t/android-deploy-script/14735)

Or, you can set the text to a gui label, so you see the message on screen.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 31, 2018, 8:49am UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/5 "2018-10-31T08:49:48Z")

</div>

> [@Pawel](#):
>
> Though, I haven’t any idea on how can I debug it on mobile

1.a. Build a debug version of your game and install it and launch it  
1.b. Or download `dmengine.apk` from [d.defold.com](http://d.defold.com) and launch it  
2. Once you have this running on the same wifi as your computer your device will show up in the `Project->Target` menu  
3. Select your device in the list  
4. Set some breakpoint(s)  
5. Chose `Debug->Run with debugger`  
6. print() statements will show up in the Console and you’ll be able to hit breakpoints and step through your code from the editor.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [October 31, 2018, 11:07am UTC](https://forum.defold.com/t/virtual-game-pad-example/33335/6 "2018-10-31T11:07:37Z")

</div>

Thank you for your ideas, I’ll try them 😉
