feat : mobile input controller
This commit is contained in:
@@ -27,14 +27,28 @@ var _repeat_timer: float = 0.0
|
||||
var _initial_repeat: bool = true
|
||||
|
||||
func _ready():
|
||||
# Set minimum size for touch target
|
||||
custom_minimum_size = Vector2(joystick_radius * 2 + 40, joystick_radius * 2 + 40)
|
||||
_update_minimum_size()
|
||||
center_position = size / 2
|
||||
|
||||
# Enable touch input
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
set_process(true)
|
||||
|
||||
func set_radius(new_radius: float):
|
||||
joystick_radius = new_radius
|
||||
# Proportional knob
|
||||
knob_radius = new_radius * (25.0 / 60.0)
|
||||
|
||||
_update_minimum_size()
|
||||
# Optional: recalculate center if already initialized
|
||||
if is_inside_tree():
|
||||
center_position = size / 2
|
||||
queue_redraw()
|
||||
|
||||
func _update_minimum_size():
|
||||
custom_minimum_size = Vector2(joystick_radius * 2 + 40, joystick_radius * 2 + 40)
|
||||
size = custom_minimum_size
|
||||
|
||||
func _draw():
|
||||
# Draw base circle
|
||||
var base_circle_color = pressed_color if is_pressed else base_color
|
||||
|
||||
Reference in New Issue
Block a user