Ui Rebuild and Full Controller Support #59
1 changed files with 12 additions and 16 deletions
|
@ -71,20 +71,16 @@ func sub_on_death(callback : Callable):
|
||||||
func update_animation():
|
func update_animation():
|
||||||
match self.velocity:
|
match self.velocity:
|
||||||
Vector2.ZERO: animation_player.play("Idle")
|
Vector2.ZERO: animation_player.play("Idle")
|
||||||
_: handle_diagonal_animations(self.velocity)
|
_:
|
||||||
pass
|
var left_dot = Vector2.LEFT.dot(self.velocity)
|
||||||
|
var right_dot = Vector2.RIGHT.dot(self.velocity)
|
||||||
func handle_diagonal_animations(dir : Vector2):
|
var up_dot = Vector2.UP.dot(self.velocity)
|
||||||
|
var down_dot = Vector2.DOWN.dot(self.velocity)
|
||||||
var left_dot = Vector2.LEFT.dot(dir)
|
|
||||||
var right_dot = Vector2.RIGHT.dot(dir)
|
var max_dot = maxf(left_dot, maxf(right_dot, maxf(up_dot, down_dot)))
|
||||||
var up_dot = Vector2.UP.dot(dir)
|
match max_dot:
|
||||||
var down_dot = Vector2.DOWN.dot(dir)
|
left_dot: animation_player.play("MoveLeft")
|
||||||
|
right_dot: animation_player.play("MoveRight")
|
||||||
var max_dot = minf(left_dot, minf(right_dot, minf(up_dot, down_dot)))
|
up_dot: animation_player.play("MoveUp")
|
||||||
match max_dot:
|
down_dot: animation_player.play("MoveDown")
|
||||||
left_dot: animation_player.play("MoveLeft")
|
|
||||||
right_dot: animation_player.play("MoveRight")
|
|
||||||
up_dot: animation_player.play("MoveUp")
|
|
||||||
down_dot: animation_player.play("MoveDown")
|
|
||||||
pass
|
pass
|
||||||
|
|
Reference in a new issue