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->height = texture->getPixelsHigh();
|
||||
self->width = texture->getContentSize().width;
|
||||
self->height = texture->getContentSize().height;}
|
||||
self->height = texture->getContentSize().height;
|
||||
}
|
||||
|
||||
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||
((TextureAtlas*)self->rendererObject)->release();
|
||||
|
@ -54,8 +55,8 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
|||
char* _spUtil_readFile (const char* path, int* length) {
|
||||
ssize_t size;
|
||||
char* data = reinterpret_cast<char*>(
|
||||
FileUtils::getInstance()->getFileData( FileUtils::getInstance()->fullPathForFilename(path).c_str(), "r", &size));
|
||||
*length = size;
|
||||
FileUtils::getInstance()->getFileData( FileUtils::getInstance()->fullPathForFilename(path).c_str(), "rb", &size));
|
||||
*length = static_cast<int>(size);
|
||||
return data;}
|
||||
|
||||
/**/
|
||||
|
|
|
@ -47,36 +47,57 @@ void SpineTestScene::runThisTest()
|
|||
}
|
||||
|
||||
bool SpineTestLayer::init () {
|
||||
if (!Layer::init()) return false;
|
||||
|
||||
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;
|
||||
|
||||
skeletonNode->runAction(RepeatForever::create(Sequence::create(FadeOut::create(1),
|
||||
FadeIn::create(1),
|
||||
DelayTime::create(5),
|
||||
NULL)));
|
||||
|
||||
Size windowSize = Director::getInstance()->getWinSize();
|
||||
skeletonNode->setPosition(Point(windowSize.width / 2, 20));
|
||||
addChild(skeletonNode);
|
||||
|
||||
scheduleUpdate();
|
||||
|
||||
return true;
|
||||
if (!Layer::init()) return false;
|
||||
|
||||
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
||||
skeletonNode->setMix("walk", "jump", 0.2f);
|
||||
skeletonNode->setMix("jump", "walk", 0.4f);
|
||||
|
||||
skeletonNode->setAnimationListener(this, animationStateEvent_selector(SpineTestLayer::animationStateEvent));
|
||||
skeletonNode->setAnimation(0, "walk", false);
|
||||
skeletonNode->addAnimation(0, "jump", false);
|
||||
skeletonNode->addAnimation(0, "walk", true);
|
||||
skeletonNode->addAnimation(0, "jump", true, 4);
|
||||
// skeletonNode->addAnimation(1, "drawOrder", true);
|
||||
|
||||
skeletonNode->timeScale = 0.3f;
|
||||
skeletonNode->debugBones = true;
|
||||
skeletonNode->update(0);
|
||||
|
||||
skeletonNode->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1),
|
||||
CCFadeIn::create(1),
|
||||
CCDelayTime::create(5),
|
||||
NULL)));
|
||||
|
||||
Size windowSize = Director::getInstance()->getWinSize();
|
||||
skeletonNode->setPosition(Point(windowSize.width / 2, 20));
|
||||
addChild(skeletonNode);
|
||||
|
||||
scheduleUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpineTestLayer::update (float deltaTime) {
|
||||
if (skeletonNode->states[0]->loop) {
|
||||
if (skeletonNode->states[0]->time > 2)
|
||||
skeletonNode->setAnimation("jump", false);
|
||||
} else {
|
||||
if (skeletonNode->states[0]->time > 1)
|
||||
skeletonNode->setAnimation("walk", true);
|
||||
|
||||
}
|
||||
|
||||
void SpineTestLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
||||
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 void update (float deltaTime);
|
||||
|
||||
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||
|
||||
CREATE_FUNC (SpineTestLayer);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1d6f59e3732b50c100af321f566c36be2576714c
|
|
@ -1 +1 @@
|
|||
c22eca8f608170bab4ceb0086e48999fb2e3d32b
|
||||
c89eb3a469e797df40e9f119b16866acc040a9e0
|
|
@ -0,0 +1 @@
|
|||
1d6f59e3732b50c100af321f566c36be2576714c
|
Loading…
Reference in New Issue