Closed UnreALi closed 5 months ago
Hello,
you shouldn't use a container for the joystick, just use their transform to change their position, size and anchors.
Containers should be used for static ui elements (buttons, sprites, etc) in a grid/row/column, where you don't want to change their size and position individually.
@MarcoFazioRandom Why should we not dynamically resize the UI element containing the joystick? What kind of problem does this cause?
Do you really care about landscape portrait mode transitions for a mobile game tool?
Finally, I need a motion joystick that will work on 3/2 of the screen, how can I achieve this without using a container?
@UnreALi,
Why should we not dynamically resize the UI element containing the joystick? What kind of problem does this cause?
Resizing the UI is not the problem, the problem is putting the joysticks inside a container, it will complicate things and not work properly, even with your solution.
I need a motion joystick that will work on 3/2 of the screen, how can I achieve this without using a container?
Using the node's anchors, margins, position, size: size_and_anchors.
I'm pretty new to godot. I approach containers as a simple responsive tool and I don't understand why using them would complicate things (I come from web technologies). However, I should point out that I have been using my solution for a few days and I have not encountered any problems.
Apart from that, I still have no idea how to create a joystick that will cover 3/2 of the screen at all sizes using anchors, margins, position, etc.
Look, I don't want to sound unfriendly, if you made it work, good for you, but just for future reference let me point out some things:
I don't get what you mean by "covering 3/2 of the screen", do you mean that if the screen if 1920x1080 you want the joystick are to cover an area of 640x540? You can do that also without container.
I don't get why you would use a container over just setting the size of the joystick area, did you take a look at the Test scene? In a 1920x1080 screen you would set the anchors to the left-bottom corner, the size to 640x540. Not everything needs to be inside a container.
The container is useful if you have several elements, in a grid/list. Using a container for 1 single Node is useless.
Online you can find many tutorials about these Node, UI, anchors, etc, I suggest you to take a look.
One last thing: The issue you opened, "Wrong reset position on HBoxContainer sizing" is not related to a bug or something to change in the code, that's way I closed it.
Of course I don't think you're being unfriendly. I'm just trying to understand
Responsive design from web technologies is a very basic concept. At the end of the day, we are trying to achieve the same user interface and the same user experience on different screen aspect ratios.
I don't get what you mean by "covering 3/2 of the screen", do you mean that if the screen if 1920x1080 you want the joystick are to cover an area of 640x540? You can do that also without container.
I want it to cover an area of 1280x1080 for 1920x1080, 426x540 for a 640x540 screen. More simply I want the motion joystick to have a stretch ratio of 2:1
For example, let's assume that our game will work on both iphone 4s and iphone 14. These devices have different screen aspect ratios. When we use a fixed size, we have the same aspect ratio for different devices. This creates dead zones where our joystick did not work on different devices.
Something like this?
Here are the settings I've set:
For the comment above: I used a ColorRect to simulate the screen but you get the general idea.
I am trying to use 2 joysticks by separating the left 3/2 and 3/1 of the screen.
When I place my joysticks in a HBoxContainer, the reset positions are incorrect.
https://github.com/MarcoFazioRandom/Virtual-Joystick-Godot/assets/23552481/08035f7e-0af7-44c9-b243-5ff046592697