浏览代码

Allow changing player facing side while in the air

* As soon as the user wants to change direction while in the air, change
  the character's facing side.
* This allows for example shooting left then right while in the air and
  gives a better feeling.

Adapted from @stormi's 8ff2aec4f160f055b5433dcc1f0bf7c166c9c125.
Rémi Verschelde 8 年之前
父节点
当前提交
cbccc3a3da
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      2d/platformer/player.gd

+ 8 - 0
2d/platformer/player.gd

@@ -119,6 +119,14 @@ func _integrate_forces(s):
 
 
 	# Process jump
 	# Process jump
 	if (jumping):
 	if (jumping):
+		# We want the character to immediately change facing side when the player
+		# tries to change direction, during air control.
+		# This allows for example the player to shoot quickly left then right.
+		if (move_left and not move_right):
+			get_node("sprite").set_scale(Vector2(-1, 1))
+		if (move_right and not move_left):
+			get_node("sprite").set_scale(Vector2(1, 1))
+
 		if (lv.y > 0):
 		if (lv.y > 0):
 			# Set off the jumping flag if going down
 			# Set off the jumping flag if going down
 			jumping = false
 			jumping = false