mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Adds Binary support to cocos2d-x (#716)
- it simplifies the constructors/initializors - the binary API is ::createWithBinaryFile() - the JSON API is :: createWithJsonFile() - the old API ::createWithDataFile() is deprecated and calls createWithJsonFile()
This commit is contained in:
parent
ea0c2ae704
commit
efe0b55dbb
@ -72,24 +72,46 @@ void disposeTrackEntry (spTrackEntry* entry) {
|
||||
//
|
||||
|
||||
SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation(skeletonData, ownsSkeletonData);
|
||||
SkeletonAnimation* node = new SkeletonAnimation();
|
||||
node->initWithData(skeletonData, ownsSkeletonData);
|
||||
node->autorelease();
|
||||
return node;
|
||||
}
|
||||
|
||||
SkeletonAnimation* SkeletonAnimation::createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale);
|
||||
SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation();
|
||||
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
|
||||
node->autorelease();
|
||||
return node;
|
||||
}
|
||||
|
||||
SkeletonAnimation* SkeletonAnimation::createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
||||
SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation();
|
||||
spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
|
||||
node->initWithJsonFile(skeletonJsonFile, atlas, scale);
|
||||
node->autorelease();
|
||||
return node;
|
||||
}
|
||||
|
||||
SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation();
|
||||
node->initWithBinaryFile(skeletonBinaryFile, atlas, scale);
|
||||
node->autorelease();
|
||||
return node;
|
||||
}
|
||||
|
||||
SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale) {
|
||||
SkeletonAnimation* node = new SkeletonAnimation();
|
||||
spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
|
||||
node->initWithBinaryFile(skeletonBinaryFile, atlas, scale);
|
||||
node->autorelease();
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void SkeletonAnimation::initialize () {
|
||||
super::initialize();
|
||||
|
||||
_ownsAnimationStateData = true;
|
||||
_state = spAnimationState_create(spAnimationStateData_create(_skeleton->data));
|
||||
_state->rendererObject = this;
|
||||
@ -103,21 +125,6 @@ SkeletonAnimation::SkeletonAnimation ()
|
||||
: SkeletonRenderer() {
|
||||
}
|
||||
|
||||
SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData, bool ownsSkeletonData)
|
||||
: SkeletonRenderer(skeletonData, ownsSkeletonData) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
SkeletonAnimation::SkeletonAnimation (const std::string& skeletonDataFile, spAtlas* atlas, float scale)
|
||||
: SkeletonRenderer(skeletonDataFile, atlas, scale) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
SkeletonAnimation::SkeletonAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale)
|
||||
: SkeletonRenderer(skeletonDataFile, atlasFile, scale) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
SkeletonAnimation::~SkeletonAnimation () {
|
||||
if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data);
|
||||
spAnimationState_dispose(_state);
|
||||
@ -167,7 +174,7 @@ spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const std::string
|
||||
}
|
||||
|
||||
spAnimation* SkeletonAnimation::findAnimation(const std::string& name) const {
|
||||
return spSkeletonData_findAnimation(_skeleton->data, name.c_str());
|
||||
return spSkeletonData_findAnimation(_skeleton->data, name.c_str());
|
||||
}
|
||||
|
||||
spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) {
|
||||
|
||||
@ -49,17 +49,30 @@ class SkeletonAnimation: public SkeletonRenderer {
|
||||
public:
|
||||
CREATE_FUNC(SkeletonAnimation);
|
||||
static SkeletonAnimation* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||
static SkeletonAnimation* createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||
static SkeletonAnimation* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
||||
static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1);
|
||||
static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1);
|
||||
static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale = 1);
|
||||
static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale = 1);
|
||||
|
||||
virtual void update (float deltaTime);
|
||||
// Use createWithJsonFile instead
|
||||
CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1)
|
||||
{
|
||||
return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlas, scale);
|
||||
}
|
||||
// Use createWithJsonFile instead
|
||||
CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1)
|
||||
{
|
||||
return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlasFile, scale);
|
||||
}
|
||||
|
||||
virtual void update (float deltaTime) override;
|
||||
|
||||
void setAnimationStateData (spAnimationStateData* stateData);
|
||||
void setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration);
|
||||
|
||||
spTrackEntry* setAnimation (int trackIndex, const std::string& name, bool loop);
|
||||
spTrackEntry* addAnimation (int trackIndex, const std::string& name, bool loop, float delay = 0);
|
||||
spAnimation* findAnimation(const std::string& name) const;
|
||||
spAnimation* findAnimation(const std::string& name) const;
|
||||
spTrackEntry* getCurrent (int trackIndex = 0);
|
||||
void clearTracks ();
|
||||
void clearTrack (int trackIndex = 0);
|
||||
@ -81,11 +94,8 @@ public:
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
SkeletonAnimation ();
|
||||
SkeletonAnimation (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||
SkeletonAnimation (const std::string&skeletonDataFile, spAtlas* atlas, float scale = 1);
|
||||
SkeletonAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
||||
virtual ~SkeletonAnimation ();
|
||||
void initialize ();
|
||||
virtual void initialize () override;
|
||||
|
||||
protected:
|
||||
spAnimationState* _state;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user