Deleting and adding SpriteFrames in another scene

Godot Version

4.3.stable

Question

`I have skins_screen.tscn and skins_screen.gd files seen in image 1. I have also player.tscn and player.gd seen in image 2. I have instantiated child scene of player.tscn in world.tscn.


Image 1


Image 2

I would like use skins_screen.tscn scene’s File Dialog to choose image file to be used as a player character skin (SpriteFrames). Image file has several frames in it 32x32 pixels each.

Right now I have hard coded animation update so when file is chosen it changes Global.default_skin value to 0. When pressing reset button it is changed back to 1. Either idle animation and its SpriteFrames are used or idle_2 animation and its Spriteframes are used and so on. That’s how func update_animations works right now.

The problem is that I would like use a script to delete SpriteFrames from idle_2 and add new SpriteFrames from chosen image file.
→ is it possible to run a function that is in another gd file to change SpriteFrames that are in another scene? Choose image file in skins_screen.gd and skins_screen.tscn and use function in player.gd to delete and add Sprite Frames of AnimatedSprite2D in player.tscn.

I have read about Atlas Texture but I’m not sure about it.

`

I also want to give credits to GitHub - tomice/super-bread-girl: 🕹️ Super Bread Girl 🍞 Fast-paced platformer prototype inspired by Super Meat Boy written in Godot 4 in which this is based.

So far I managed get the Animation name with get_animation(). I’ve not been succesful with Animation Frames / SpriteFrames manipulation.