Browse Source

Merge pull request #35 from stormi/aircontrol

Allow changing player facing side while in the air
Rémi Verschelde 8 years ago
parent
commit
dfabaa7ba7
1 changed files with 8 additions and 1 deletions
  1. 8 1
      2d/platformer/player.gd

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

@@ -85,7 +85,14 @@ func _fixed_process(delta):
 			new_anim="run"
 			
 	else:
-		
+		# 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 (Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right")):
+			sprite.set_scale( Vector2( -1, 1 ) )
+		if (Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_left")):
+			sprite.set_scale( Vector2( 1, 1 ) )
+
 		if (linear_vel.y < 0 ):
 			new_anim="jumping"
 		else: