本文整理汇总了C++中ActionTimeline类的典型用法代码示例。如果您正苦于以下问题:C++ ActionTimeline类的具体用法?C++ ActionTimeline怎么用?C++ ActionTimeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionTimeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: animateHitPiece
void MainScene::animateHitPiece(Side obstacleSide)
{
Piece* flyingPiece = dynamic_cast<Piece*>(CSLoader::createNode("Piece.csb"));
ActionTimeline* pieceTimeline = CSLoader::createTimeline("Piece.csb");
flyingPiece->setObstacleSide(obstacleSide);
flyingPiece->setPosition(this->flyingPiecePosition);
this->addChild(flyingPiece);
this->runAction(pieceTimeline);
switch (this->character->getSide()) {
case Side::Left:
pieceTimeline->play("moveRight", false);
break;
case Side::Right:
pieceTimeline->play("moveLeft", false);
break;
default:
break;
}
// on the last frame of the animation, remove the piece from the scene
pieceTimeline->setLastFrameCallFunc([this, &flyingPiece]() {
this->removeChild(flyingPiece);
});
}
示例2: CCLOG
ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(const std::string&fileName, const std::string& content)
{
// if already exists an action with filename, then return this action
ActionTimeline* action = _animationActions.at(fileName);
if(action)
return action;
rapidjson::Document doc;
doc.Parse<0>(content.c_str());
if (doc.HasParseError())
{
CCLOG("GetParseError %s\n", doc.GetParseError());
}
const rapidjson::Value& json = DICTOOL->getSubDictionary_json(doc, ACTION);
action = ActionTimeline::create();
action->setDuration(DICTOOL->getIntValue_json(json, DURATION));
action->setTimeSpeed(DICTOOL->getFloatValue_json(json, TIME_SPEED, 1.0f));
int timelineLength = DICTOOL->getArrayCount_json(json, TIMELINES);
for (int i = 0; i<timelineLength; i++)
{
const rapidjson::Value& dic = DICTOOL->getSubDictionary_json(json, TIMELINES, i);
Timeline* timeline = loadTimeline(dic);
if(timeline)
action->addTimeline(timeline);
}
_animationActions.insert(fileName, action);
return action;
}
示例3: GetCSParseBinary
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName)
{
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
fbs->_isSimulator = true;
auto builder = fbs->createFlatBuffersWithXMLFileForSimulator(fileName);
ActionTimeline* action = ActionTimeline::create();
auto csparsebinary = GetCSParseBinary(builder->GetBufferPointer());
auto nodeAction = csparsebinary->action();
action = ActionTimeline::create();
int duration = nodeAction->duration();
action->setDuration(duration);
float speed = nodeAction->speed();
action->setTimeSpeed(speed);
auto timeLines = nodeAction->timeLines();
int timelineLength = timeLines->size();
for (int i = 0; i < timelineLength; i++)
{
auto timelineFlatBuf = timeLines->Get(i);
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
if (timeline)
action->addTimeline(timeline);
}
fbs->deleteFlatBufferBuilder();
return action;
}
示例4: init
bool WelcomeStudioScene::init(){
if (!CCLayer::init()) {
return false;
}
m_rootNode=NodeReader::getInstance()->createNode("Blackcat_1/Blackcat_1.ExportJson");
ActionTimeline* action = ActionTimelineCache::getInstance()->createAction("Blackcat_1/Blackcat_1.ExportJson");
m_rootNode->runAction(action);
action->gotoFrameAndPlay(0, action->getDuration(), true);
for (int i=0; i<m_rootNode->getChildrenCount(); i++) {
Widget* child=(Widget*)m_rootNode->getChildren()->objectAtIndex(i);
if (child->getTag()==-1) {
Button* button=(Button*)UIHelper::seekWidgetByTag(child, 136);
if(button){
button->addTouchEventListener(this, toucheventselector(WelcomeStudioScene::touchEvent));
}
}
}
this->addChild(m_rootNode);
return true;
}
示例5: createActionFromJson
ActionTimeline* ActionTimelineCache::createActionFromJson(const std::string& fileName)
{
ActionTimeline* action = _animationActions.at(fileName);
if (action == nullptr)
{
action = loadAnimationActionWithFile(fileName);
}
return action->clone();
}
示例6: createActionWithDataBuffer
ActionTimeline* ActionTimelineCache::createActionWithDataBuffer(Data data, const std::string &fileName)
{
ActionTimeline* action = _animationActions.at(fileName);
if (action == NULL)
{
action = loadAnimationWithDataBuffer(data, fileName);
}
return action->clone();
}
示例7: createAction
ActionTimeline* ActionTimelineCache::createAction(const std::string& fileName)
{
ActionTimeline* action = static_cast<ActionTimeline*>(_timelineActions->objectForKey(fileName));
if (action == NULL)
{
action = loadAnimationActionWithFile(fileName);
}
return action->clone();
}
示例8: createActionWithFlatBuffersFile
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersFile(const std::string &fileName)
{
ActionTimeline* action = _animationActions.at(fileName);
if (action == NULL)
{
action = loadAnimationActionWithFlatBuffersFile(fileName);
}
return action->clone();
}
示例9: new
// ActionTimeline
ActionTimeline* ActionTimeline::create()
{
ActionTimeline* object = new (std::nothrow) ActionTimeline();
if (object && object->init())
{
object->autorelease();
return object;
}
CC_SAFE_DELETE(object);
return nullptr;
}
示例10: onEnter
// TestActionTimelineBlendFuncFrame
void TestActionTimelineBlendFuncFrame::onEnter()
{
ActionTimelineBaseTest::onEnter();
Node* node = CSLoader::createNode("ActionTimeline/skeletonBlendFuncFrame.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/skeletonBlendFuncFrame.csb");
node->runAction(action);
node->setScale(0.2f);
node->setPosition(VisibleRect::center());
this->addChild(node);
action->gotoFrameAndPlay(0);
}
示例11:
void TestActionTimelineIssueWith2SameActionInOneNode::onEnter()
{
CCFileUtils::getInstance()->addSearchPath("ActionTimeline");
ActionTimelineBaseTest::onEnter();
Node* node = CSLoader::createNode("ani2.csb");
ActionTimeline* action = CSLoader::createTimeline("ani2.csb");
node->setPosition(Vec2(150, 100));
node->runAction(action);
action->gotoFrameAndPlay(0);
this->addChild(node);
}
示例12: CC_ASSERT
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(const std::string &fileName)
{
// if already exists an action with filename, then return this action
ActionTimeline* action = _animationActions.at(fileName);
if (action)
return action;
std::string path = fileName;
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName.c_str());
CC_ASSERT(FileUtils::getInstance()->isFileExist(fullPath));
Data buf = FileUtils::getInstance()->getDataFromFile(fullPath);
auto csparsebinary = GetCSParseBinary(buf.getBytes());
auto nodeAction = csparsebinary->action();
action = ActionTimeline::create();
int duration = nodeAction->duration();
action->setDuration(duration);
float speed = nodeAction->speed();
action->setTimeSpeed(speed);
auto animationlist = csparsebinary->animationList();
int animationcount = animationlist->size();
for (int i = 0; i < animationcount; i++)
{
auto animationdata = animationlist->Get(i);
AnimationInfo info;
info.name = animationdata->name()->c_str();
info.startIndex = animationdata->startIndex();
info.endIndex = animationdata->endIndex();
action->addAnimationInfo(info);
}
auto timelines = nodeAction->timeLines();
int timelineLength = timelines->size();
for (int i = 0; i < timelineLength; i++)
{
auto timelineFlatBuf = timelines->Get(i);
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
if (timeline)
action->addTimeline(timeline);
}
_animationActions.insert(fileName, action);
return action;
}
示例13: triggerActionTimeline
void MainScene::triggerActionTimeline(string animationName, bool loop)
{
// we pass "MainScene.csb" to the constructor
// so this ActionTimeline will be able to play any of the animations
// that we've created in MainScene.csd
ActionTimeline* timeline = CSLoader::createTimeline("MainScene.csb");
ERROR_HANDLING(timeline);
//this->stopAllActions(); // cancel any currently running actions on MainScene
this->runAction(timeline); // we tell MainScene to run the timeline
timeline->play(animationName, loop);
}
示例14: GetCSParseBinary
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName)
{
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
fbs->_isSimulator = true;
auto builder = fbs->createFlatBuffersWithXMLFileForSimulator(fileName);
ActionTimeline* action = ActionTimeline::create();
auto csparsebinary = GetCSParseBinary(builder->GetBufferPointer());
auto nodeAction = csparsebinary->action();
action = ActionTimeline::create();
int duration = nodeAction->duration();
action->setDuration(duration);
float speed = nodeAction->speed();
action->setTimeSpeed(speed);
auto animationlist = csparsebinary->animationList();
int animationcount = animationlist->size();
for (int i = 0; i < animationcount; i++)
{
auto animationdata = animationlist->Get(i);
AnimationInfo info;
info.name = animationdata->name()->c_str();
info.startIndex = animationdata->startIndex();
info.endIndex = animationdata->endIndex();
action->addAnimationInfo(info);
}
auto timeLines = nodeAction->timeLines();
int timelineLength = timeLines->size();
std::multimap<std::string, cocostudio::timeline::Timeline*> properTimelineMap;// order the timelines depends property name
for (int i = 0; i < timelineLength; i++)
{
auto timelineFlatBuf = timeLines->Get(i);
Timeline* timeline = loadTimelineWithFlatBuffers(timelineFlatBuf);
if (timeline)
{
properTimelineMap.insert(std::make_pair(timelineFlatBuf->property()->c_str(), timeline));
}
}
for (const auto& properTimelinePair : properTimelineMap)
{
action->addTimeline(properTimelinePair.second);
}
fbs->deleteFlatBufferBuilder();
return action;
}
示例15: CC_CALLBACK_1
//TestTimelineNodeLoadedCallback
void TestTimelineNodeLoadedCallback::onEnter()
{
ActionTimelineBaseTest::onEnter();
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb", CC_CALLBACK_1(TestTimelineNodeLoadedCallback::nodeLoadedCallback,
this));
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(0);
// ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true);
node->setScale(0.2f);
node->setPosition(VisibleRect::center());
addChild(node);
}