mirror of https://github.com/axmolengine/axmol.git
Updates spine test.
This commit is contained in:
parent
df85ba8fd9
commit
cfec4d5b7e
|
@ -45,7 +45,8 @@ void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||||
// self->width = texture->getPixelsWide();
|
// self->width = texture->getPixelsWide();
|
||||||
// self->height = texture->getPixelsHigh();
|
// self->height = texture->getPixelsHigh();
|
||||||
self->width = texture->getContentSize().width;
|
self->width = texture->getContentSize().width;
|
||||||
self->height = texture->getContentSize().height;}
|
self->height = texture->getContentSize().height;
|
||||||
|
}
|
||||||
|
|
||||||
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||||
((TextureAtlas*)self->rendererObject)->release();
|
((TextureAtlas*)self->rendererObject)->release();
|
||||||
|
@ -54,8 +55,8 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||||
char* _spUtil_readFile (const char* path, int* length) {
|
char* _spUtil_readFile (const char* path, int* length) {
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
char* data = reinterpret_cast<char*>(
|
char* data = reinterpret_cast<char*>(
|
||||||
FileUtils::getInstance()->getFileData( FileUtils::getInstance()->fullPathForFilename(path).c_str(), "r", &size));
|
FileUtils::getInstance()->getFileData( FileUtils::getInstance()->fullPathForFilename(path).c_str(), "rb", &size));
|
||||||
*length = size;
|
*length = static_cast<int>(size);
|
||||||
return data;}
|
return data;}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
|
@ -47,36 +47,57 @@ void SpineTestScene::runThisTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineTestLayer::init () {
|
bool SpineTestLayer::init () {
|
||||||
if (!Layer::init()) return false;
|
if (!Layer::init()) return false;
|
||||||
|
|
||||||
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
||||||
skeletonNode->setMix("walk", "jump", 0.4f);
|
skeletonNode->setMix("walk", "jump", 0.2f);
|
||||||
skeletonNode->setMix("jump", "walk", 0.4f);
|
skeletonNode->setMix("jump", "walk", 0.4f);
|
||||||
skeletonNode->setAnimation("walk", true);
|
|
||||||
|
skeletonNode->setAnimationListener(this, animationStateEvent_selector(SpineTestLayer::animationStateEvent));
|
||||||
skeletonNode->timeScale = 0.3f;
|
skeletonNode->setAnimation(0, "walk", false);
|
||||||
skeletonNode->debugBones = true;
|
skeletonNode->addAnimation(0, "jump", false);
|
||||||
|
skeletonNode->addAnimation(0, "walk", true);
|
||||||
skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1),
|
skeletonNode->addAnimation(0, "jump", true, 4);
|
||||||
FadeIn::create(1),
|
// skeletonNode->addAnimation(1, "drawOrder", true);
|
||||||
DelayTime::create(5),
|
|
||||||
NULL)));
|
skeletonNode->timeScale = 0.3f;
|
||||||
|
skeletonNode->debugBones = true;
|
||||||
Size windowSize = Director::getInstance()->getWinSize();
|
skeletonNode->update(0);
|
||||||
skeletonNode->setPosition(Point(windowSize.width / 2, 20));
|
|
||||||
addChild(skeletonNode);
|
skeletonNode->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1),
|
||||||
|
CCFadeIn::create(1),
|
||||||
scheduleUpdate();
|
CCDelayTime::create(5),
|
||||||
|
NULL)));
|
||||||
return true;
|
|
||||||
|
Size windowSize = Director::getInstance()->getWinSize();
|
||||||
|
skeletonNode->setPosition(Point(windowSize.width / 2, 20));
|
||||||
|
addChild(skeletonNode);
|
||||||
|
|
||||||
|
scheduleUpdate();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineTestLayer::update (float deltaTime) {
|
void SpineTestLayer::update (float deltaTime) {
|
||||||
if (skeletonNode->states[0]->loop) {
|
|
||||||
if (skeletonNode->states[0]->time > 2)
|
}
|
||||||
skeletonNode->setAnimation("jump", false);
|
|
||||||
} else {
|
void SpineTestLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
if (skeletonNode->states[0]->time > 1)
|
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
||||||
skeletonNode->setAnimation("walk", true);
|
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case ANIMATION_START:
|
||||||
|
log("%d start: %s", trackIndex, animationName);
|
||||||
|
break;
|
||||||
|
case ANIMATION_END:
|
||||||
|
log("%d end: %s", trackIndex, animationName);
|
||||||
|
break;
|
||||||
|
case ANIMATION_COMPLETE:
|
||||||
|
log("%d complete: %s, %d", trackIndex, animationName, loopCount);
|
||||||
|
break;
|
||||||
|
case ANIMATION_EVENT:
|
||||||
|
log("%d event: %s, %s: %d, %f, %s", trackIndex, animationName, event->data->name, event->intValue, event->floatValue, event->stringValue);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
|
|
||||||
virtual bool init ();
|
virtual bool init ();
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
|
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
CREATE_FUNC (SpineTestLayer);
|
CREATE_FUNC (SpineTestLayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1d6f59e3732b50c100af321f566c36be2576714c
|
|
@ -1 +1 @@
|
||||||
c22eca8f608170bab4ceb0086e48999fb2e3d32b
|
c89eb3a469e797df40e9f119b16866acc040a9e0
|
|
@ -0,0 +1 @@
|
||||||
|
1d6f59e3732b50c100af321f566c36be2576714c
|
Loading…
Reference in New Issue