How to flip a sprite with a virtual joystick

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Torvic

I’m using this Virtual Joystick on my game and I don’t know where to put the flip_h = true

if joystick and joystick.is_pressed():
	position += joystick.get_output() * speed * delta

	$AnimatedSprite.animation = "run"
	$AnimatedSprite.playing = true	
	
else:
	$AnimatedSprite.animation = "idle"
:bust_in_silhouette: Reply From: estebanmolca

Hi, this should work:

if joystick and joystick.is_pressed():
    position += joystick.get_output() * speed * delta

    $AnimatedSprite.animation = "run"
    $AnimatedSprite.playing = true 

    if   joystick.get_output().x < 0:
        flip_h = true
    if   joystick.get_output().x > 0:
        flip_h = false

else:
    $AnimatedSprite.animation = "idle"

IT WORKED!! Thank you so much <3

Torvic | 2022-08-17 23:11