Update spine runtime

This commit is contained in:
flaming0 2013-06-02 19:59:13 +04:00
parent 5f1a4a4be7
commit b87a89eaa4
3 changed files with 14 additions and 9 deletions

View File

@ -73,7 +73,9 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \
../spine/Slot.cpp \
../spine/SlotData.cpp \
../spine/extension.cpp \
../spine/spine-cocos2dx.cpp
../spine/spine-cocos2dx.cpp \
../spine/CCSkeleton.cpp \
../spine/CCSkeletonAnimation.cpp
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk

View File

@ -48,10 +48,11 @@ void SpineTestScene::runThisTest()
bool SpineTestLayer::init () {
if (!CCLayer::init()) return false;
skeletonNode = CCSkeleton::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
AnimationStateData_setMixByName(skeletonNode->state->data, "walk", "jump", 0.4f);
AnimationStateData_setMixByName(skeletonNode->state->data, "jump", "walk", 0.4f);
AnimationState_setAnimationByName(skeletonNode->state, "walk", true);
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
skeletonNode->setMix("walk", "jump", 0.4f);
skeletonNode->setMix("jump", "walk", 0.4f);
skeletonNode->setAnimation("walk", true);
skeletonNode->timeScale = 0.3f;
skeletonNode->debugBones = true;
@ -70,9 +71,11 @@ bool SpineTestLayer::init () {
}
void SpineTestLayer::update (float deltaTime) {
if (skeletonNode->state->loop) {
if (skeletonNode->state->time > 2) AnimationState_setAnimationByName(skeletonNode->state, "jump", false);
if (skeletonNode->states[0]->loop) {
if (skeletonNode->states[0]->time > 2)
skeletonNode->setAnimation("jump", false);
} else {
if (skeletonNode->state->time > 1) AnimationState_setAnimationByName(skeletonNode->state, "walk", true);
if (skeletonNode->states[0]->time > 1)
skeletonNode->setAnimation("walk", true);
}
}

View File

@ -38,7 +38,7 @@ public:
class SpineTestLayer: public cocos2d::CCLayer {
private:
cocos2d::extension::CCSkeleton* skeletonNode;
cocos2d::extension::CCSkeletonAnimation* skeletonNode;
public: