diff --git a/spine-godot/spine_godot/SpineTimeline.cpp b/spine-godot/spine_godot/SpineTimeline.cpp index c8509ed6b..2c05df6f9 100644 --- a/spine-godot/spine_godot/SpineTimeline.cpp +++ b/spine-godot/spine_godot/SpineTimeline.cpp @@ -30,6 +30,7 @@ #include "SpineTimeline.h" #include "SpineSkeleton.h" #include "SpineEvent.h" +#include "SpineCommon.h" #include "core/method_bind_ext.gen.inc" void SpineTimeline::_bind_methods() { @@ -45,55 +46,55 @@ void SpineTimeline::_bind_methods() { SpineTimeline::SpineTimeline() : timeline(NULL) { } -SpineTimeline::~SpineTimeline() { -} - -void SpineTimeline::apply(Ref skeleton, float lastTime, float time, Array events, float alpha, +void SpineTimeline::apply(Ref skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) { - spine::Vector spineEvents; - spineEvents.setSize(events.size(), nullptr); - for (size_t i = 0; i < events.size(); ++i) { - events[i] = ((Ref) spineEvents[i])->get_spine_object(); + SPINE_CHECK(timeline,) + spine::Vector spine_events; + spine_events.setSize((int)events.size(), nullptr); + for (int i = 0; i < events.size(); ++i) { + events[i] = ((Ref) spine_events[i])->get_spine_object(); } - timeline->apply(*(skeleton->get_spine_object()), lastTime, time, &spineEvents, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction); + timeline->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction); } int64_t SpineTimeline::get_frame_entries() { + SPINE_CHECK(timeline, 0) return timeline->getFrameEntries(); } int64_t SpineTimeline::get_frame_count() { + SPINE_CHECK(timeline, 0) return timeline->getFrameCount(); } Array SpineTimeline::get_frames() { - auto &frames = timeline->getFrames(); Array result; - result.resize(frames.size()); - - for (size_t i = 0; i < result.size(); ++i) { + SPINE_CHECK(timeline, result) + auto &frames = timeline->getFrames(); + result.resize((int)frames.size()); + for (int i = 0; i < result.size(); ++i) { result[i] = frames[i]; } - return result; } float SpineTimeline::get_duration() { + SPINE_CHECK(timeline, 0) return timeline->getDuration(); } Array SpineTimeline::get_property_ids() { - auto &ids = timeline->getPropertyIds(); Array result; - result.resize(ids.size()); - - for (size_t i = 0; i < result.size(); ++i) { + SPINE_CHECK(timeline, result) + auto &ids = timeline->getPropertyIds(); + result.resize((int)ids.size()); + for (int i = 0; i < result.size(); ++i) { result[i] = (int64_t) ids[i]; } - return result; } String SpineTimeline::get_type() { + SPINE_CHECK(timeline, "") return timeline->getRTTI().getClassName(); } diff --git a/spine-godot/spine_godot/SpineTimeline.h b/spine-godot/spine_godot/SpineTimeline.h index e29e6953f..23a76dafa 100644 --- a/spine-godot/spine_godot/SpineTimeline.h +++ b/spine-godot/spine_godot/SpineTimeline.h @@ -30,9 +30,9 @@ #ifndef GODOT_SPINETIMELINE_H #define GODOT_SPINETIMELINE_H -#include "spine/Timeline.h" #include "SpineConstant.h" #include "core/reference.h" +#include class SpineSkeleton; class SpineEvent; @@ -48,12 +48,11 @@ private: public: SpineTimeline(); - ~SpineTimeline(); - inline void set_spine_object(spine::Timeline *timeline) { this->timeline = timeline; } - inline spine::Timeline *get_spine_object() { return timeline; } + void set_spine_object(spine::Timeline *timeline) { this->timeline = timeline; } + spine::Timeline *get_spine_object() { return timeline; } - void apply(Ref skeleton, float lastTime, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction); + void apply(Ref skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction); int64_t get_frame_entries();