LoginSignup
6
7

More than 5 years have passed since last update.

CocosStudioで作成したSceneをLoadする cocos2d-x_3.4

Last updated at Posted at 2015-03-21

環境

  • Cocos2d-x_3.4
  • Cocos Studio for Mac 2.1.2Beta

手順

  1. Cocos StudioでPublishしたresフォルダをプロジェクトに追加する
  2. 追加する際は Create folder references を選択
  3. シーンでロードする

# CocosGUI.h, CocoStudio.h をインポートする。
# 適宜 namespace を使用する。

HelloWorldScene.m
#include "ui/CocosGUI.h"
#include "cocostudio/CocoStudio.h"

using namespace cocostudio;
using namespace ui;

bool HelloWorld::init()
{
    if( !Layer::init() )
    {
        return false;
    }
    // (中略)

    // searchPathを追加する
    // 実際、createSceneする前のAppDelegate.cpp applicationDidFinishLaunching()など初期化時に行っておけば良いと思う
    FileUtils::getInstance()->addSearchPath("res");

    // ロードする
    auto mainScene = CSLoader::getInstance()->createNode("res/MainScene.csb");
    this->addChild(mainScene);

    return true;
}

参考

cocos2d-x: CSLoader Class Reference

6
7
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
6
7