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.
0 votes

I created scene with complex button. When you touch it. Joystick appears and button disapears. Then you can swipe to any direction. Everything in 1 motion and last position saves in Global variable. joysticks hides and button appears again.

extends Control

var pressed = false

func analog_force_change(inForce, inAnalog):
        if inForce.x == 0 and inForce.y == 0:
           pressed = false

func _on_Button_mouse_enter():
   if pressed == true:

func _on_Button_focus_enter():
    pressed = true

Everything works as I typed above. The problem is when I try to instance these nodes to another scene...Its far away from working. No value in Global and joystick stays visible. Even it feels very different and ALL I did was instanced fully working button scene...

in Engine by (330 points)
edited by

Are the corresponding signals connected? Unlike functions like "_ready()" the callback functions for button clicks need to be connected.

By the way I recommend that you don't use globals. Godot makes it so easy to use object orientation that there's no need to go out of your way to break encapsulation. Why not have your game read the input values from the joystick object rather than from a global variable? That way you will run into less trouble in the long run e.g. when you want to add another player or have different joysticks affect different elements in the game.

1, I will try to not use globals.
2, The button scene is working correctly even when I exported it to android but when I put it to other scene then It stops working.

found the problem
When instanced I had to change listener node from root/action to root/ui/action

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.