LoginSignup
9
9

More than 5 years have passed since last update.

Cocos Studio 2.0を使ってみる

Last updated at Posted at 2015-01-06

インストール

Cocos2d-x Downloadsからダウンロードして、インストールする。
現在の最新バージョンは 2.0.6。

サーチパス追加

    std::vector<std::string> searchPaths;
    searchPaths.push_back("csb");
    FileUtils::getInstance()->setSearchPaths(searchPaths);

csbファイルを使う

#include "cocostudio/CocoStudio.h"

auto node = CSLoader::getInstance()->createNodeWithFlatBuffersFile("csb/MyNode.csb");

アニメーション

#include "cocostudio/CocoStudio.h"

Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(0, 40, true);

    auto action = CSLoader::getInstance()->createTimeline("csb/MainScene.csb");
    mainScene->runAction(action);
    action->gotoFrameAndPlay(0, 60, true);

フレームイベント

    auto action = CSLoader::getInstance()->createTimeline("csb/MainScene.csb");
    mainScene->runAction(action);
    action->gotoFrameAndPlay(0, 60, true);
    using namespace cocostudio::timeline;
    action->setFrameEventCallFunc([this](Frame *frame) {
        EventFrame* eFrame = dynamic_cast<EventFrame *>(frame);
        auto eName = eFrame->getEvent();
        CCLOG("frame event: %d, %s", frame->getFrameIndex(), eName.c_str());
        auto target = eFrame->getNode();
        if (eName == "big") {
            target->setScale(1.5f);
        } else if (eName == "small") {
            target->setScale(1.0f);
        }
    });

参考

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9