[godot] Added example showing how to load files from disk.

This commit is contained in:
Mario Zechner 2024-10-02 16:38:49 +02:00
parent 7e6671456b
commit 7897cffb3b
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dr1u7vj8mm6ed"]
[ext_resource type="Script" path="res://examples/13-load-from-disk/load_from_disk.gd" id="1_krs2n"]
[node name="Load-from-disk" type="Node2D"]
script = ExtResource("1_krs2n")

View File

@ -0,0 +1,24 @@
extends Node2D
func _ready():
# Load the skeleton file
var skeleton_file_res = SpineSkeletonFileResource.new();
skeleton_file_res.load_from_file("/Users/badlogic/workspaces/spine-runtimes/examples/coin/export/coin-pro.skel");
# Load the atlas file
var atlas_res = SpineAtlasResource.new();
atlas_res.load_from_atlas_file("/Users/badlogic/workspaces/spine-runtimes/examples/coin/export/coin.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("animation", true, 0);
self.add_child(sprite)
pass