restructured folders
This commit is contained in:
parent
e3aec75404
commit
0f5045dc22
22 changed files with 32 additions and 21 deletions
38
ui/camera_controls.gd
Normal file
38
ui/camera_controls.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
extends Control
|
||||
|
||||
var pressed: bool = false
|
||||
var previous_position : Vector2 = Vector2.ZERO
|
||||
var speed : float = 0.04
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
# Filter touch or drag events only.
|
||||
if event is not InputEventScreenTouch and event is not InputEventScreenDrag:
|
||||
return
|
||||
|
||||
if event is InputEventScreenTouch:
|
||||
if event.is_pressed():
|
||||
pressed = true
|
||||
else:
|
||||
pressed = false
|
||||
simulate_joystick_motion(JOY_AXIS_RIGHT_X, 0, 0)
|
||||
|
||||
if pressed and event is InputEventScreenDrag:
|
||||
var delta_position : Vector2 = event.position - previous_position
|
||||
print(delta_position)
|
||||
simulate_joystick_motion(JOY_AXIS_RIGHT_X, -delta_position.x * speed, 0)
|
||||
#simulate_joystick_motion(JOY_AXIS_RIGHT_Y, delta_position.y * speed, 0)
|
||||
|
||||
# finally update the previous position
|
||||
previous_position = event.position
|
||||
|
||||
func simulate_joystick_motion(axis: int, value: float, device_id: int = 0) -> void:
|
||||
var joystick_event = InputEventJoypadMotion.new()
|
||||
joystick_event.device = device_id
|
||||
joystick_event.axis = axis # Axis index (e.g., 0 for X-axis, 1 for Y-axis)
|
||||
joystick_event.axis_value = value # Value of the axis, typically between -1 and 1
|
||||
|
||||
Input.parse_input_event(joystick_event) # Process the event
|
||||
Loading…
Add table
Add a link
Reference in a new issue