Is there a way to flip my sprite left and right depending on where are my mouse at?
Flipping sprite
- Edited
You could use the rotate() method, or the rotation or rotation_degrees properties.
Never mind, that wouldn't flip it the way you want.
Welcome to the forums @NetherBoy!
You can flip a sprite using scale.x = -1
and flip it back using scale.x = 1
. For detecting the mouse, you can use something like this (untested):
var local_mouse_pos = get_local_mouse_position()
if (local_mouse_pos.x < 0):
scale.x = -1
else:
scale.x = 1
You can also use the flip_h property to flip a Sprite node horizontally as well, though children nodes will be unaffected.
oww I get the idea thank you so much dude!
3 years later
hey so this is more of question but how would you make a sprite go vertically like how you can with the flip_h
- Edited
ironson118 you can use the method above, just use scale.y = 1
or scale.y = -1
for reverse/mirror.