diff --git a/spine-godot/example/examples/07-slot-node/slot-node.gd b/spine-godot/example/examples/07-slot-node/slot-node.gd new file mode 100644 index 000000000..44704bffb --- /dev/null +++ b/spine-godot/example/examples/07-slot-node/slot-node.gd @@ -0,0 +1,6 @@ +extends Node2D + +onready var spineboy: SpineSprite = $Spineboy + +func _ready(): + spineboy.get_animation_state().set_animation("walk", true, 0) diff --git a/spine-godot/example/examples/07-slot-node/slot-node.tscn b/spine-godot/example/examples/07-slot-node/slot-node.tscn new file mode 100644 index 000000000..6e7afd66b --- /dev/null +++ b/spine-godot/example/examples/07-slot-node/slot-node.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://examples/07-slot-node/slot-node.gd" type="Script" id=1] +[ext_resource path="res://assets/spineboy/spinebody-data-res.tres" type="SpineSkeletonDataResource" id=2] +[ext_resource path="res://icon.png" type="Texture" id=3] + +[node name="Node2D" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Spineboy" type="SpineSprite" parent="."] +position = Vector2( 506, 480 ) +scale = Vector2( 0.560712, 0.560712 ) +skeleton_data_res = ExtResource( 2 ) + +[node name="SpineSlotNode" type="SpineSlotNode" parent="Spineboy"] +position = Vector2( 40.8752, -276.036 ) +rotation = 0.837234 +scale = Vector2( 1, 1 ) +slot_name = "gun" + +[node name="Sprite" type="Sprite" parent="Spineboy/SpineSlotNode"] +texture = ExtResource( 3 ) diff --git a/spine-godot/example/project.godot b/spine-godot/example/project.godot index b52e4a317..d72ceb1de 100644 --- a/spine-godot/example/project.godot +++ b/spine-godot/example/project.godot @@ -11,7 +11,7 @@ config_version=4 [application] config/name="spine-godot-examples" -run/main_scene="res://examples/01-helloworld/helloworld.tscn" +run/main_scene="res://examples/07-slot-node/slot-node.tscn" run/low_processor_mode=true config/icon="res://icon.png" diff --git a/spine-godot/spine_godot/SpineBone.cpp b/spine-godot/spine_godot/SpineBone.cpp index 74a0edc41..a9fe2f4c0 100644 --- a/spine-godot/spine_godot/SpineBone.cpp +++ b/spine-godot/spine_godot/SpineBone.cpp @@ -101,10 +101,6 @@ void SpineBone::_bind_methods() { SpineBone::SpineBone() : bone(nullptr), sprite(nullptr) {} -void SpineBone::set_spine_sprite(SpineSprite* _sprite) { - this->sprite = _sprite; -} - void SpineBone::update_world_transform() { SPINE_CHECK(bone,) bone->updateWorldTransform(); @@ -166,8 +162,7 @@ Ref SpineBone::get_skeleton() { SPINE_CHECK(bone, nullptr) auto &skeleton = bone->getSkeleton(); Ref skeleton_ref(memnew(SpineSkeleton)); - skeleton_ref->set_spine_object(&skeleton); - skeleton_ref->set_spine_sprite(sprite); + skeleton_ref->set_spine_object(sprite, &skeleton); return skeleton_ref; } @@ -176,8 +171,7 @@ Ref SpineBone::get_parent() { auto parent = bone->getParent(); if (!parent) return nullptr; Ref parent_ref(memnew(SpineBone)); - parent_ref->set_spine_object(parent); - parent_ref->set_spine_sprite(sprite); + parent_ref->set_spine_object(sprite, parent); return parent_ref; } @@ -189,8 +183,7 @@ Array SpineBone::get_children() { for (int i = 0; i < children.size(); ++i) { auto child = children[i]; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(child); - bone_ref->set_spine_sprite(sprite); + bone_ref->set_spine_object(sprite, child); result[i] = bone_ref; } return result; diff --git a/spine-godot/spine_godot/SpineBone.h b/spine-godot/spine_godot/SpineBone.h index 60af690fb..0f05e0f9b 100644 --- a/spine-godot/spine_godot/SpineBone.h +++ b/spine-godot/spine_godot/SpineBone.h @@ -51,11 +51,9 @@ private: public: SpineBone(); - void set_spine_object(spine::Bone *_bone) { bone = _bone; } - + void set_spine_object(SpineSprite *_sprite, spine::Bone *_bone) { sprite = _sprite; bone = _bone; } spine::Bone *get_spine_object() { return bone; } - - void set_spine_sprite(SpineSprite* _sprite); + SpineSprite *get_spine_sprite() { return sprite; } void update_world_transform(); diff --git a/spine-godot/spine_godot/SpineIkConstraint.cpp b/spine-godot/spine_godot/SpineIkConstraint.cpp index 3c7ae6fef..6fc24bcf3 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.cpp +++ b/spine-godot/spine_godot/SpineIkConstraint.cpp @@ -52,7 +52,7 @@ void SpineIkConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineIkConstraint::set_active); } -SpineIkConstraint::SpineIkConstraint() : ik_constraint(nullptr) { +SpineIkConstraint::SpineIkConstraint() : ik_constraint(nullptr), sprite(nullptr) { } void SpineIkConstraint::update() { @@ -81,7 +81,7 @@ Array SpineIkConstraint::get_bones() { for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); + bone_ref->set_spine_object(sprite, bone); result[i] = bone_ref; } return result; @@ -92,7 +92,7 @@ Ref SpineIkConstraint::get_target() { auto target = ik_constraint->getTarget(); if (!target) return nullptr; Ref target_ref(memnew(SpineBone)); - target_ref->set_spine_object(target); + target_ref->set_spine_object(sprite, target); return target_ref; } diff --git a/spine-godot/spine_godot/SpineIkConstraint.h b/spine-godot/spine_godot/SpineIkConstraint.h index b4b2c53f5..01c11c420 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.h +++ b/spine-godot/spine_godot/SpineIkConstraint.h @@ -34,6 +34,7 @@ #include class SpineBone; +class SpineSprite; class SpineIkConstraint : public REFCOUNTED { GDCLASS(SpineIkConstraint, REFCOUNTED); @@ -43,13 +44,14 @@ protected: private: spine::IkConstraint *ik_constraint; + SpineSprite *sprite; public: SpineIkConstraint(); - void set_spine_object(spine::IkConstraint *_ik_constraint) { ik_constraint = _ik_constraint; } - + void set_spine_object(SpineSprite *_sprite, spine::IkConstraint *_ik_constraint) { sprite = _sprite; ik_constraint = _ik_constraint; } spine::IkConstraint *get_spine_object() { return ik_constraint; } + SpineSprite *get_spine_sprite() { return sprite; } void update(); diff --git a/spine-godot/spine_godot/SpinePathConstraint.cpp b/spine-godot/spine_godot/SpinePathConstraint.cpp index eaa750894..0864d4708 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.cpp +++ b/spine-godot/spine_godot/SpinePathConstraint.cpp @@ -52,7 +52,7 @@ void SpinePathConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "v"), &SpinePathConstraint::set_active); } -SpinePathConstraint::SpinePathConstraint() : path_constraint(nullptr) { +SpinePathConstraint::SpinePathConstraint() : path_constraint(nullptr), sprite(nullptr) { } void SpinePathConstraint::update() { @@ -123,7 +123,7 @@ Array SpinePathConstraint::get_bones() { for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); + bone_ref->set_spine_object(sprite, bone); result[i] = bone_ref; } return result; @@ -134,7 +134,7 @@ Ref SpinePathConstraint::get_target() { auto target = path_constraint->getTarget(); if (!target) return nullptr; Ref target_ref(memnew(SpineSlot)); - target_ref->set_spine_object(target); + target_ref->set_spine_object(sprite, target); return target_ref; } diff --git a/spine-godot/spine_godot/SpinePathConstraint.h b/spine-godot/spine_godot/SpinePathConstraint.h index 5d1a01fe8..722756e27 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.h +++ b/spine-godot/spine_godot/SpinePathConstraint.h @@ -42,12 +42,14 @@ protected: private: spine::PathConstraint *path_constraint; + SpineSprite *sprite; public: SpinePathConstraint(); - void set_spine_object(spine::PathConstraint *_path_constraint) { path_constraint = _path_constraint; } + void set_spine_object(SpineSprite *_sprite, spine::PathConstraint *_path_constraint) { sprite = _sprite; path_constraint = _path_constraint; } spine::PathConstraint *get_spine_object() { return path_constraint; } + SpineSprite *get_spine_sprite() { return sprite; } void update(); diff --git a/spine-godot/spine_godot/SpineSkeleton.cpp b/spine-godot/spine_godot/SpineSkeleton.cpp index 56facbb50..41e5db191 100644 --- a/spine-godot/spine_godot/SpineSkeleton.cpp +++ b/spine-godot/spine_godot/SpineSkeleton.cpp @@ -87,10 +87,6 @@ Ref SpineSkeleton::get_skeleton_data_res() const { return skeleton_data_res; } -void SpineSkeleton::set_spine_sprite(SpineSprite* _sprite) { - this->sprite = _sprite; -} - void SpineSkeleton::update_world_transform() { SPINE_CHECK(skeleton,) skeleton->updateWorldTransform(); @@ -117,8 +113,7 @@ Ref SpineSkeleton::find_bone(const String &name) { auto bone = skeleton->findBone(SPINE_STRING(name)); if (!bone) return nullptr; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); - bone_ref->set_spine_sprite(sprite); + bone_ref->set_spine_object(sprite, bone); return bone_ref; } @@ -128,7 +123,7 @@ Ref SpineSkeleton::find_slot(const String &name) { auto slot = skeleton->findSlot(SPINE_STRING(name)); if (!slot) return nullptr; Ref slot_ref(memnew(SpineSlot)); - slot_ref->set_spine_object(slot); + slot_ref->set_spine_object(sprite, slot); return slot_ref; } @@ -171,7 +166,7 @@ Ref SpineSkeleton::find_ik_constraint(const String &constrain auto constraint = skeleton->findIkConstraint(SPINE_STRING(constraint_name)); if (!constraint) return nullptr; Ref constraint_ref(memnew(SpineIkConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); return constraint_ref; } @@ -181,7 +176,7 @@ Ref SpineSkeleton::find_transform_constraint(const Str auto constraint = skeleton->findTransformConstraint(SPINE_STRING(constraint_name)); if (!constraint) return nullptr; Ref constraint_ref(memnew(SpineTransformConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); return constraint_ref; } @@ -191,7 +186,7 @@ Ref SpineSkeleton::find_path_constraint(const String &const auto constraint = skeleton->findPathConstraint(SPINE_STRING(constraint_name)); if (!constraint) return nullptr; Ref constraint_ref(memnew(SpinePathConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); return constraint_ref; } @@ -207,8 +202,7 @@ Ref SpineSkeleton::get_root_bone() { auto bone = skeleton->getRootBone(); if (!bone) return nullptr; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); - bone_ref->set_spine_sprite(sprite); + bone_ref->set_spine_object(sprite, bone); return bone_ref; } @@ -220,8 +214,7 @@ Array SpineSkeleton::get_bones() { for (int i = 0; i < result.size(); ++i) { auto bone = bones[i]; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); - bone_ref->set_spine_sprite(sprite); + bone_ref->set_spine_object(sprite, bone); result[i] = bone_ref; } return result; @@ -235,7 +228,7 @@ Array SpineSkeleton::get_slots() { for (int i = 0; i < result.size(); ++i) { auto slot = slots[i]; Ref slot_ref(memnew(SpineSlot)); - slot_ref->set_spine_object(slot); + slot_ref->set_spine_object(sprite, slot); result[i] = slot_ref; } return result; @@ -249,7 +242,7 @@ Array SpineSkeleton::get_draw_order() { for (int i = 0; i < result.size(); ++i) { auto slot = slots[i]; Ref slot_ref(memnew(SpineSlot)); - slot_ref->set_spine_object(slot); + slot_ref->set_spine_object(sprite, slot); result[i] = slot_ref; } return result; @@ -263,7 +256,7 @@ Array SpineSkeleton::get_ik_constraints() { for (int i = 0; i < result.size(); ++i) { auto constraint = constraints[i]; Ref constraint_ref(memnew(SpineIkConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); result[i] = constraint_ref; } return result; @@ -277,7 +270,7 @@ Array SpineSkeleton::get_path_constraints() { for (int i = 0; i < result.size(); ++i) { auto constraint = constraints[i]; Ref constraint_ref(memnew(SpinePathConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); result[i] = constraint_ref; } return result; @@ -290,7 +283,7 @@ Array SpineSkeleton::get_transform_constraints() { for (int i = 0; i < result.size(); ++i) { auto constraint = constraints[i]; Ref constraint_ref(memnew(SpineTransformConstraint)); - constraint_ref->set_spine_object(constraint); + constraint_ref->set_spine_object(sprite, constraint); result[i] = constraint_ref; } return result; diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index d4fddbf6a..09d3050b6 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -57,10 +57,10 @@ protected: void set_skeleton_data_res(Ref data_res); Ref get_skeleton_data_res() const; - void set_spine_object(spine::Skeleton *s) { skeleton = s; } + void set_spine_object(SpineSprite *_sprite, spine::Skeleton *_skeleton) { sprite = _sprite; skeleton = _skeleton; } spine::Skeleton *get_spine_object() { return skeleton; } - - void set_spine_sprite(SpineSprite *sprite); + void set_spine_sprite(SpineSprite *_sprite) { sprite = _sprite; } + SpineSprite *get_spine_sprite() { return sprite; } private: spine::Skeleton *skeleton; diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index e77ce8e98..e5f231efe 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -223,6 +223,16 @@ void SpineSkeletonDataResource::get_skin_names(Vector &skin_names) const } } +void SpineSkeletonDataResource::get_slot_names(Vector& slot_names) { + slot_names.clear(); + if (!is_skeleton_data_loaded()) return; + auto slots = skeleton_data->getSlots(); + for (size_t i = 0; i < slots.size(); ++i) { + auto slot = slots[i]; + slot_names.push_back(slot->getName().buffer()); + } +} + void SpineSkeletonDataResource::set_default_mix(float _default_mix) { this->default_mix = _default_mix; update_mixes(); diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.h b/spine-godot/spine_godot/SpineSkeletonDataResource.h index d30e6a0f5..250fb8a2b 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.h +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.h @@ -76,6 +76,8 @@ public: void get_skin_names(Vector &l) const; + void get_slot_names(Vector &slot_names); + void set_default_mix(float default_mix); float get_default_mix(); diff --git a/spine-godot/spine_godot/SpineSlot.cpp b/spine-godot/spine_godot/SpineSlot.cpp index e38bf9739..fb55d944c 100644 --- a/spine-godot/spine_godot/SpineSlot.cpp +++ b/spine-godot/spine_godot/SpineSlot.cpp @@ -52,7 +52,7 @@ void SpineSlot::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sequence_index", "v"), &SpineSlot::set_sequence_index); } -SpineSlot::SpineSlot() : slot(nullptr) { +SpineSlot::SpineSlot() : slot(nullptr), sprite(nullptr) { } void SpineSlot::set_to_setup_pose() { @@ -72,7 +72,7 @@ Ref SpineSlot::get_bone() { SPINE_CHECK(slot, nullptr) auto &bone = slot->getBone(); Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(&bone); + bone_ref->set_spine_object(sprite, &bone); return bone_ref; } @@ -80,7 +80,7 @@ Ref SpineSlot::get_skeleton() { SPINE_CHECK(slot, nullptr) auto &skeleton = slot->getSkeleton(); Ref skeleton_ref(memnew(SpineSkeleton)); - skeleton_ref->set_spine_object(&skeleton); + skeleton_ref->set_spine_object(sprite, &skeleton); return skeleton_ref; } diff --git a/spine-godot/spine_godot/SpineSlot.h b/spine-godot/spine_godot/SpineSlot.h index 107fa31b0..ec1624db0 100644 --- a/spine-godot/spine_godot/SpineSlot.h +++ b/spine-godot/spine_godot/SpineSlot.h @@ -46,12 +46,14 @@ protected: private: spine::Slot *slot; + SpineSprite *sprite; public: SpineSlot(); - void set_spine_object(spine::Slot *s) { slot = s; } + void set_spine_object(SpineSprite *_sprite, spine::Slot *_slot) { sprite = _sprite; slot = _slot; } spine::Slot *get_spine_object() { return slot; } + SpineSprite *get_spine_sprite() { return sprite; } void set_to_setup_pose(); diff --git a/spine-godot/spine_godot/SpineSlotNode.cpp b/spine-godot/spine_godot/SpineSlotNode.cpp new file mode 100644 index 000000000..adea25ae5 --- /dev/null +++ b/spine-godot/spine_godot/SpineSlotNode.cpp @@ -0,0 +1,79 @@ +#include "SpineSlotNode.h" + +void SpineSlotNode::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_slot_name"), &SpineSlotNode::set_slot_name); + ClassDB::bind_method(D_METHOD("get_slot_name"), &SpineSlotNode::get_slot_name); + ClassDB::bind_method(D_METHOD("_on_world_transforms_changed", "spine_sprite"), &SpineSlotNode::on_world_transforms_changed); +} + +SpineSlotNode::SpineSlotNode(): sprite(nullptr) { +} + +void SpineSlotNode::_notification(int what) { + switch(what) { + case NOTIFICATION_PARENTED: { + sprite = Object::cast_to(get_parent()); + if (sprite) { + sprite->connect("world_transforms_changed", this, "_on_world_transforms_changed"); + } else { + WARN_PRINT("SpineSlotProxy parent is not a SpineSprite."); + } + NOTIFY_PROPERTY_LIST_CHANGED(); + break; + } + case NOTIFICATION_UNPARENTED: { + if (sprite) { + sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed"); + } + } + default: + break; + } +} + +void SpineSlotNode::_get_property_list(List* list) const { + Vector slot_names; + if (sprite) sprite->get_skeleton_data_res()->get_slot_names(slot_names); + else slot_names.push_back(slot_name); + PropertyInfo slot_name_property; + slot_name_property.name = "slot_name"; + slot_name_property.type = Variant::STRING; + slot_name_property.hint_string = String(",").join(slot_names); + slot_name_property.hint = PROPERTY_HINT_ENUM; + slot_name_property.usage = PROPERTY_USAGE_DEFAULT; + list->push_back(slot_name_property); +} + +bool SpineSlotNode::_get(const StringName& property, Variant& value) const { + if (property == "slot_name") { + value = slot_name; + return true; + } + return false; +} + +bool SpineSlotNode::_set(const StringName& property, const Variant& value) { + if (property == "slot_name") { + slot_name = value; + return true; + } + return false; +} + +void SpineSlotNode::on_world_transforms_changed(const Variant& _sprite) { + SpineSprite* sprite = Object::cast_to(_sprite.operator Object*()); + if (!sprite) return; + auto slot = sprite->get_skeleton()->find_slot(slot_name); + if (!slot.is_valid()) return; + auto bone = slot->get_bone(); + if (!bone.is_valid()) return; + this->set_global_transform(bone->get_global_transform()); +} + +void SpineSlotNode::set_slot_name(const String& _slot_name) { + slot_name = _slot_name; +} + +String SpineSlotNode::get_slot_name() { + return slot_name; +} diff --git a/spine-godot/spine_godot/SpineSlotNode.h b/spine-godot/spine_godot/SpineSlotNode.h new file mode 100644 index 000000000..a3d4d5086 --- /dev/null +++ b/spine-godot/spine_godot/SpineSlotNode.h @@ -0,0 +1,29 @@ +#ifndef GODOT_SPINESLOTNODE_H +#define GODOT_SPINESLOTNODE_H + +#include "SpineCommon.h" +#include "SpineSprite.h" +#include "scene/2d/node_2d.h" + +class SpineSlotNode: public Node2D { + GDCLASS(SpineSlotNode, Node2D) + +protected: + String slot_name; + SpineSprite *sprite; + + static void _bind_methods(); + void _notification(int what); + void _get_property_list(List *list) const; + bool _get(const StringName &property, Variant &value) const; + bool _set(const StringName &property, const Variant &value); + void on_world_transforms_changed(const Variant &_sprite); +public: + SpineSlotNode(); + + void set_slot_name(const String &_slot_name); + + String get_slot_name(); +}; + +#endif diff --git a/spine-godot/spine_godot/SpineTransformConstraint.cpp b/spine-godot/spine_godot/SpineTransformConstraint.cpp index b7283911e..9f88d1313 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraint.cpp @@ -52,7 +52,7 @@ void SpineTransformConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineTransformConstraint::set_active); } -SpineTransformConstraint::SpineTransformConstraint() : transform_constraint(nullptr) { +SpineTransformConstraint::SpineTransformConstraint() : transform_constraint(nullptr), sprite(nullptr) { } void SpineTransformConstraint::update() { @@ -81,7 +81,7 @@ Array SpineTransformConstraint::get_bones() { for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; Ref bone_ref(memnew(SpineBone)); - bone_ref->set_spine_object(bone); + bone_ref->set_spine_object(sprite, bone); result[i] = bone_ref; } return result; @@ -92,7 +92,7 @@ Ref SpineTransformConstraint::get_target() { auto target = transform_constraint->getTarget(); if (!target) return nullptr; Ref target_ref(memnew(SpineBone)); - target_ref->set_spine_object(target); + target_ref->set_spine_object(sprite, target); return target_ref; } diff --git a/spine-godot/spine_godot/SpineTransformConstraint.h b/spine-godot/spine_godot/SpineTransformConstraint.h index 37ef5db49..764c81998 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.h +++ b/spine-godot/spine_godot/SpineTransformConstraint.h @@ -43,12 +43,14 @@ protected: private: spine::TransformConstraint *transform_constraint; + SpineSprite *sprite; public: SpineTransformConstraint(); - void set_spine_object(spine::TransformConstraint *tc) { transform_constraint = tc; } + void set_spine_object(SpineSprite *_sprite, spine::TransformConstraint *_transform_constraint) { sprite = _sprite; transform_constraint = _transform_constraint; } spine::TransformConstraint *get_spine_object() { return transform_constraint; } + SpineSprite *get_spine_sprite() { return sprite; } void update(); diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index b0088a47a..3b3ce37ed 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -49,6 +49,7 @@ #include "SpineTimeline.h" #include "SpineConstant.h" #include "SpineCollisionShapeProxy.h" +#include "SpineSlotNode.h" static Ref atlas_loader; static Ref atlas_saver; @@ -98,6 +99,7 @@ void register_spine_godot_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); #if VERSION_MAJOR > 3 atlas_loader.instantiate();