Loading from the user://
dir works as intended. I put spineboy-pro.skel
and spineboy.atlas
/spineboy.png
into
/Users/badlogic/Library/Application Support/Godot/app_userdata/spine-godot-examples/save/animation
To simulate your setup. spine-godot-examples
is the project name. In your case it's DesktopPets.
I then load the skeleton and atlas via this code:
extends Node2D
func _ready():
# Load the skeleton file
var skeleton_file_res = SpineSkeletonFileResource.new();
var error = skeleton_file_res.load_from_file("user://save/animation/spineboy-pro.skel");
if (error != OK):
print("Could not load skeleton")
# Load the atlas file
var atlas_res = SpineAtlasResource.new();
error = atlas_res.load_from_atlas_file("user://save/animation/spineboy.atlas");
if (error != OK):
print("Could not load atlas")
# Create a skeleton data resource, you can share this across multiple sprites
var skeleton_data_res = SpineSkeletonDataResource.new();
skeleton_data_res.skeleton_file_res = skeleton_file_res;
skeleton_data_res.atlas_res = atlas_res
# Create a sprite from the skeleton data and add it as a child
var sprite = SpineSprite.new();
sprite.skeleton_data_res = skeleton_data_res;
sprite.position.x = 200;
sprite.position.y = 200;
sprite.get_animation_state().set_animation("walk", true, 0);
self.add_child(sprite)
pass
This works as intended.