mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[godot] Clean-up SpineTimeline.
This commit is contained in:
parent
44cecb6b2d
commit
12d29a8950
@ -30,6 +30,7 @@
|
|||||||
#include "SpineTimeline.h"
|
#include "SpineTimeline.h"
|
||||||
#include "SpineSkeleton.h"
|
#include "SpineSkeleton.h"
|
||||||
#include "SpineEvent.h"
|
#include "SpineEvent.h"
|
||||||
|
#include "SpineCommon.h"
|
||||||
#include "core/method_bind_ext.gen.inc"
|
#include "core/method_bind_ext.gen.inc"
|
||||||
|
|
||||||
void SpineTimeline::_bind_methods() {
|
void SpineTimeline::_bind_methods() {
|
||||||
@ -45,55 +46,55 @@ void SpineTimeline::_bind_methods() {
|
|||||||
SpineTimeline::SpineTimeline() : timeline(NULL) {
|
SpineTimeline::SpineTimeline() : timeline(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineTimeline::~SpineTimeline() {
|
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha,
|
||||||
}
|
|
||||||
|
|
||||||
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array events, float alpha,
|
|
||||||
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
|
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
|
||||||
spine::Vector<spine::Event *> spineEvents;
|
SPINE_CHECK(timeline,)
|
||||||
spineEvents.setSize(events.size(), nullptr);
|
spine::Vector<spine::Event *> spine_events;
|
||||||
for (size_t i = 0; i < events.size(); ++i) {
|
spine_events.setSize((int)events.size(), nullptr);
|
||||||
events[i] = ((Ref<SpineEvent>) spineEvents[i])->get_spine_object();
|
for (int i = 0; i < events.size(); ++i) {
|
||||||
|
events[i] = ((Ref<SpineEvent>) 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() {
|
int64_t SpineTimeline::get_frame_entries() {
|
||||||
|
SPINE_CHECK(timeline, 0)
|
||||||
return timeline->getFrameEntries();
|
return timeline->getFrameEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t SpineTimeline::get_frame_count() {
|
int64_t SpineTimeline::get_frame_count() {
|
||||||
|
SPINE_CHECK(timeline, 0)
|
||||||
return timeline->getFrameCount();
|
return timeline->getFrameCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineTimeline::get_frames() {
|
Array SpineTimeline::get_frames() {
|
||||||
auto &frames = timeline->getFrames();
|
|
||||||
Array result;
|
Array result;
|
||||||
result.resize(frames.size());
|
SPINE_CHECK(timeline, result)
|
||||||
|
auto &frames = timeline->getFrames();
|
||||||
for (size_t i = 0; i < result.size(); ++i) {
|
result.resize((int)frames.size());
|
||||||
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
result[i] = frames[i];
|
result[i] = frames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineTimeline::get_duration() {
|
float SpineTimeline::get_duration() {
|
||||||
|
SPINE_CHECK(timeline, 0)
|
||||||
return timeline->getDuration();
|
return timeline->getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineTimeline::get_property_ids() {
|
Array SpineTimeline::get_property_ids() {
|
||||||
auto &ids = timeline->getPropertyIds();
|
|
||||||
Array result;
|
Array result;
|
||||||
result.resize(ids.size());
|
SPINE_CHECK(timeline, result)
|
||||||
|
auto &ids = timeline->getPropertyIds();
|
||||||
for (size_t i = 0; i < result.size(); ++i) {
|
result.resize((int)ids.size());
|
||||||
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
result[i] = (int64_t) ids[i];
|
result[i] = (int64_t) ids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineTimeline::get_type() {
|
String SpineTimeline::get_type() {
|
||||||
|
SPINE_CHECK(timeline, "")
|
||||||
return timeline->getRTTI().getClassName();
|
return timeline->getRTTI().getClassName();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,9 @@
|
|||||||
#ifndef GODOT_SPINETIMELINE_H
|
#ifndef GODOT_SPINETIMELINE_H
|
||||||
#define GODOT_SPINETIMELINE_H
|
#define GODOT_SPINETIMELINE_H
|
||||||
|
|
||||||
#include "spine/Timeline.h"
|
|
||||||
#include "SpineConstant.h"
|
#include "SpineConstant.h"
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
#include <spine/Timeline.h>
|
||||||
|
|
||||||
class SpineSkeleton;
|
class SpineSkeleton;
|
||||||
class SpineEvent;
|
class SpineEvent;
|
||||||
@ -48,12 +48,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SpineTimeline();
|
SpineTimeline();
|
||||||
~SpineTimeline();
|
|
||||||
|
|
||||||
inline void set_spine_object(spine::Timeline *timeline) { this->timeline = timeline; }
|
void set_spine_object(spine::Timeline *timeline) { this->timeline = timeline; }
|
||||||
inline spine::Timeline *get_spine_object() { return timeline; }
|
spine::Timeline *get_spine_object() { return timeline; }
|
||||||
|
|
||||||
void apply(Ref<SpineSkeleton> skeleton, float lastTime, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
void apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
|
||||||
|
|
||||||
int64_t get_frame_entries();
|
int64_t get_frame_entries();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user