Animating my sprite

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

This is my current script

script: Animated_Ship

extends Area2D

func _ready():
set_process(true)
set_process_input(true)
pass

func _process(delta):

tracks mouse movement to sprite

var motion = ((get_global_mouse_position().x - position.x) * 0.2)
translate(Vector2(motion, 0))

Clamp sprite to screen view

var view_size = get_viewport_rect().size 
position.x = clamp(position.x, 56, view_size.x-56)

How can i add the animation to play constantly in this script? where should i add it on this?

Im pretty bad at script so this is pretty difficult for me. any help is greatly appreciated.

You should use an AnimationPlayer node, or AnimatedSprite for making the animations, then select the current animation by code.

p7f | 2020-07-15 18:59

You can use the AnimatedSprite node.

Simon | 2020-07-27 17:30