mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 23:54:23 +00:00
Make it possible for MoveTowardsMouse
to detach and stop moving
This commit is contained in:
parent
c2dab55333
commit
45512a8ba1
2 changed files with 10 additions and 2 deletions
|
@ -3,17 +3,19 @@ class_name MoveTowardsMouse
|
|||
|
||||
|
||||
signal move(movement: Vector2)
|
||||
signal detached
|
||||
signal captured
|
||||
|
||||
|
||||
@export_range(-500, 500, 1) var speed: float = 100.0
|
||||
@export var can_detach: bool = false
|
||||
|
||||
@onready var game := MainGame.get_ancestor(self)
|
||||
|
||||
|
||||
enum State { STILL, CAPTURED }
|
||||
enum State { DETACHED, CAPTURED }
|
||||
|
||||
var state: State = State.STILL
|
||||
var state: State = State.DETACHED
|
||||
|
||||
|
||||
func get_relative_mouse_position():
|
||||
|
@ -32,3 +34,8 @@ func _physics_process(delta: float) -> void:
|
|||
func _on_capture_area_mouse_entered() -> void:
|
||||
state = State.CAPTURED
|
||||
captured.emit()
|
||||
|
||||
func _on_capture_area_mouse_exited() -> void:
|
||||
if can_detach:
|
||||
state = State.DETACHED
|
||||
detached.emit()
|
||||
|
|
|
@ -9,3 +9,4 @@ script = ExtResource("1_nbja1")
|
|||
[node name="CaptureArea" parent="." instance=ExtResource("2_qru2e")]
|
||||
|
||||
[connection signal="mouse_entered" from="CaptureArea" to="." method="_on_capture_area_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="CaptureArea" to="." method="_on_capture_area_mouse_exited"]
|
||||
|
|
Loading…
Reference in a new issue