2024-04-15 03:43:07 +00:00
|
|
|
extends Sprite2D
|
|
|
|
class_name SpriteLeftRight
|
|
|
|
|
|
|
|
|
|
|
|
@export var left_texture: Texture2D
|
|
|
|
@export var right_texture: Texture2D
|
|
|
|
|
2024-04-25 23:19:27 +00:00
|
|
|
var last_discrim: float = 0
|
2024-04-15 03:43:07 +00:00
|
|
|
|
|
|
|
func handle_move(movement: Vector2):
|
2024-04-25 23:19:27 +00:00
|
|
|
var discrim = movement.x
|
|
|
|
if discrim == 0:
|
|
|
|
discrim = last_discrim
|
|
|
|
if discrim > 0:
|
2024-04-15 03:43:07 +00:00
|
|
|
texture = right_texture
|
2024-04-25 23:19:27 +00:00
|
|
|
last_discrim = discrim
|
|
|
|
elif discrim < 0:
|
2024-04-15 03:43:07 +00:00
|
|
|
texture = left_texture
|
2024-04-25 23:19:27 +00:00
|
|
|
last_discrim = discrim
|