Prechádzať zdrojové kódy

:wrench: Make Martinus going gently at the center on start

Instead of beaming it in the center.
DricomDragon 2 rokov pred
rodič
commit
36dc957aff
1 zmenil súbory, kde vykonal 8 pridanie a 5 odobranie
  1. 8 5
      godot/component/entity/player/Player.gd

+ 8 - 5
godot/component/entity/player/Player.gd

@@ -12,11 +12,10 @@ var target_reached = true
 var _current_state
 
 
-func spawn(atPos):
+func spawn(pos):
 	_current_state = State.DODGING
-	position = atPos
 	$CollisionShape2D.disabled = false
-	$AnimatedSprite.animation = "idle"
+	go_to(pos)
 
 
 func sleep():
@@ -56,10 +55,14 @@ func dodge(delta: float):
 		$AnimatedSprite.animation = "idle"
 
 
+func go_to(pos: Vector2):
+	target = pos
+	target_reached = false
+
+
 func _input(event):
 	if event is InputEventMouseButton or event is InputEventMouseMotion :
-		target = event.position
-		target_reached = false
+		go_to(event.position)
 
 
 func _on_Player_body_entered(_body):