How do I change the texture in a sprite with the Animation player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alibix
:warning: Old Version Published before Godot 3 was released.

I have a running animation and an idle animation for a ‘player’ sprite. They are two different png spritesheets. If I wanted the player to run, how would I change the texture in the player sprite to the different spritesheet? I tried to keyframe the texture and HFrames at the start of the animation but that didn’t work.

:bust_in_silhouette: Reply From: atze

You can call a function to change the spritesheet and set set hframes

Something like:

func load_spritesheet(file, hframes):
	sprite_node.set_texture(load("res://path/to/" + file))
    sprite_node.set_hframes(hframes)
    [etc]