Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ikaro001 |
the script part is: if event is_pressed():
and the whole script:
extends Sprite
const Radius = 75
const Small_Radius = 35
var stick_pos
var evt_index = -1
func _init():
stick_pos = position
func _input(event):
if event is InputEventScreenTouch:
if event is_pressed():
if stick_pos.distance_to(event.position) < Radius:
evt_index = event.index
elif evt_index != -1:
if evt_index == event.index:
evt_index = -1
$small.position = Vector2()
$“…/”.stick_vector = Vector2()
$“…/” stick_angle = 0
$“…/” stick_speed = 0
if evt_index != -1 and event is InputEventScreenDrag:
var dist = stick_pos.distance_to(event.position)
if dis + Small_Radius > Radius:
dist = Radius - Small_Radius
var vect = (event.position - stick_pos).normalized()
var ang = event.position.angle_to_point(position)
remembering, don’t complete the script all