MarcoFazioRandom / Virtual-Joystick-Godot

A simple virtual joystick for touchscreens, for both 2D and 3D games, with useful options.
MIT License
731 stars 80 forks source link

Correct issue with changing scale of joystick at runtime #58

Closed ztc0611 closed 1 year ago

ztc0611 commented 1 year ago

If you have any method to handle window resizing which changes the scale of the joystick, the joystick ceases functioning once that runs. This fixes the issue and doesn't create any new ones as far as I can see. I don't think this has any performance hit, but if that is a concern I can modify the code to only rescale it based on a checkbox.

MarcoFazioRandom commented 1 year ago

Hello, The purpose of the var _base_radius is to calculate _base.size * _base.get_global_transform_with_canvas().get_scale() / 2 just at the start and saving the result. By recalculating it every frame its purpose is defeated. I thought of 4 better (imho) alternatives:

ztc0611 commented 1 year ago

I think I did what you intended? Tell me if it's still wrong and I'll be on it.