cocos2d-x version : 3.4 final
spine version : 2.1 (from git hub)
Hello, I asked to this problem once but, I didn't solve this problem yet.
Please help me. It is too hard for me. :sweat:
I did just modify a few line in your sample code.
It is work animation, but when I touch for replace scene then It crash.
This is the sample code that I modified.
#include "TestScene.h"
#include "SpineboyExample.h"
#include "GoblinsExample.h"
#include <iostream>
#include <fstream>
#include <string.h>
USING_NS_CC;
using namespace cocostudio;
using namespace spine;
using namespace std;
Scene* TestScene::scene () {
Scene *scene = Scene::create();
scene->addChild(TestScene::create());
return scene;
}
bool TestScene::init () {
if (!LayerColor::initWithColor(Color4B(0, 0, 0, 0))) return false;
skeletonNode = SkeletonAnimation::createWithFile("spineTest/skeleton.json", "spineTest/skeleton.atlas", 1.0f);
skeletonNode->setStartListener( [this] (int trackIndex) {
spTrackEntry* entry = spAnimationState_getCurrent(skeletonNode->getState(), trackIndex);
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
log("%d start: %s", trackIndex, animationName);
});
skeletonNode->setEndListener( [] (int trackIndex) {
log("%d end", trackIndex);
});
skeletonNode->setCompleteListener( [this] (int trackIndex, int loopCount) {
log("%d complete: %d", trackIndex, loopCount);
});
skeletonNode->setEventListener( [] (int trackIndex, spEvent* event) {
log("%d event: %s, %d, %f, %s", trackIndex, event->data->name, event->intValue, event->floatValue, event->stringValue);
});
auto entry = skeletonNode->setAnimation(0, "walk", false);
Size windowSize = Director::getInstance()->getWinSize();
skeletonNode->setPosition(Vec2(windowSize.width / 2 + 80, 100));
this->addChild(skeletonNode, 0);
scheduleUpdate();
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this] (Touch* touch, Event* event) -> bool {
if (!skeletonNode->getDebugBonesEnabled()) {
skeletonNode->setDebugBonesEnabled(true);
}
else if (skeletonNode->getTimeScale() == 1) {
skeletonNode->setTimeScale(0.3f);
}
else {
Director::getInstance()->replaceScene(SpineboyExample::scene());
}
return true;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
void TestScene::update (float deltaTime) {
// Test releasing memory.
// Director::getInstance()->replaceScene(TestScene::scene());
}
When I touch for replace scene It makes crash where Animation.c file!!
Error message is "Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)"
Animation.c 103 Line
void spTimeline_dispose (spTimeline* self) {
VTABLE(spTimeline, self)->dispose(self); -> This line makes erros!!
}
I did just played my spine data in your sample code.
And I did touched for replace scene to SpineboySample.
What did I wrong???
Please let me know what can I do???