Android joystick

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogerdv

Im trying to creat a joystick for an android project, following this tutorial https://www.youtube.com/watch?v=uGyEP2LUFPg
It works well while in its own scene, but when I add the scene to the one where I cant to use it, the center button doesnt moves and I get no results at all. Probably Im missing something (the original tutorial simply skips things or shows them too quiickly for a newbie to notice), but I cant figure out whats wrong.
Can somebody give me an idea?

“the original tutorial simply skips things or shows them too quiickly
for a newbie to notice”

If in case you didn’t see the link in the video description: compare your code with the one on your github

https://github.com/Gonkee/Gonkees-Shaders/blob/master/non-shaders/Joystick_Button.gd

estebanmolca | 2020-01-24 14:56

In my test I think it works well, put together a new 2d scene and I put a TouchScreenButton node as children and assign the github script on that node. In the properties of TouchScreenButton assign 2 different textures to Normal and Pressed, activate the touch simulation with the mouse in the project settings and the button works well, the only thing that at the beginning is positioned at the point (0,0) of the screen , I guess it has to be children of a control type node. I investigate and tell you.

My second test: it could work as a child of a control but the code had to be changed because the control nodes use rect_position instead of position. Just add another node and I put the TouchScreenButton as a child of that node, now moving the parent I place the button where I want and the moving works fine …

Node2D
----Node2D
--------TouchScreenButton <<<( contains the script)

estebanmolca | 2020-01-24 15:20