如题,为什么没有文档或范例呢?
有简单的文档,详细如何使用 creator 导出的动画,看这个头文件就可以了,只有几个方法
使用示例在
谢谢你的答复,我按照示例改了程序,发现moveby可以执行,但是AnimationClip 不能播放程序如下
testScene.h
----------
#pragma once
#include “cocos2d.h”
#include “reader\CreatorReader.h”
#include “ui/CocosGUI.h”
using namespace cocos2d;
using namespace ui;
static creator::CreatorReader* reader;
static creator::AnimationManager* AM;
static Sprite *sheep;
class testSence
{
public:
testSence();
~testSence();
Scene* scene1;
void init();
private:
ui::Button *_button;
void onRunClick(CCObject *pSender, ui::TouchEventType type);
};
testScence.cpp
#include "testSence.h"
testSence::testSence() {
init();
}
testSence::~testSence() {
reader->release();
AM->release();
}
void testSence::init()
{
reader = creator::CreatorReader::createWithFilename("creator/aa.ccreator");
// will create the needed spritesheets + design resolution
reader->setup();
// get the scene graph
scene1 = reader->getSceneGraph();
AM = reader->getAnimationManager();
sheep = (CCSprite *)scene1->getChildByName("Canvas")->getChildByName("sheep_run_0");
_button = (ui::Button*)scene1->getChildByName("Canvas")->getChildByName("run");
_button->addTouchEventListener(scene1, toucheventselector(testSence::onRunClick));
}
void testSence::onRunClick(CCObject *pSender, ui::TouchEventType type) {
switch (type)
{
case ui::TOUCH_EVENT_ENDED:
{
printf("clicked\n");
AM->retain();
//AM->playAnimationClip(sheep, "sheepRun");
sheep->runAction(Sequence::create(
MoveBy::create(0.05, Point(sheep->getBoundingBox().size.width*0.05, 0)),
DelayTime::create(1),
CallFunc::create([=]() {
AM->playAnimationClip(sheep, "sheepRun");
}),
DelayTime::create(1),
CallFunc::create([=]() {
AM->resumeAnimationClip(sheep, "sheepRun");
}),
nullptr));
break;
}
default:
break;
}
}
调试中加了输出
void AnimationManager::runAnimationClip(cocos2d::Node *target, AnimationClip* animationClip)
{
auto animate = AnimateClip::createWithAnimationClip(target, animationClip);
animate->retain();
this->retain();
animate->setCallbackForEndevent([=]() {
removeAnimateClip(target, animationClip->getName());
printf("animationClip is removed!\n");
this->release();
});
animate->startAnimate();
_cachedAnimates.push_back(std::make_tuple(target, animationClip->getName(), animate));
printf("_cachedAnimates.size:%d\n", _cachedAnimates.size());
}
这个函数正确执行
暂时没时间看,建议修改一下贴代码的方式,代码粘贴到 markdown 代码块中