COCOS2DX-3.3調用COCOSTUDIO1.6中的SCENE和UI

    auto scene = SceneReader::getInstance()->createNodeWithSceneFile("publish/FirstScene.json");
    assert(nullptr != scene);
    addChild(scene);
    auto sceneChild = scene->getChildByTag(10010);
    assert(nullptr != sceneChild);
    auto uiReader = static_cast<ComRender*>(sceneChild->getComponent("GUIComponent"));
    assert(nullptr != uiReader);
    auto uiLayer = static_cast<Layout*>(uiReader->getNode());
    assert(nullptr != uiLayer);

    auto uiButton = (ui::Button*)ui::Helper::seekWidgetByName(uiLayer, "button_close");
    assert(nullptr != uiButton);
    uiButton->addClickEventListener(CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));

	auto reader = GUIReader::getInstance();
	auto mainLayout = dynamic_cast<Layout*>(reader->widgetFromJsonFile("DemoLogin.json"));

    ArmatureDataManager::getInstance()->addArmatureFileInfo("TestAnimation/TestAnimation.ExportJson");
    auto armature = Armature::create("TestAnimation");//project name
    assert(nullptr != armature);
    armature->setPosition(Vec2(Director::getInstance()->getWinSize().width * 0.5f, Director::sharedDirector()->getWinSize().height * 0.5f));
    addChild(armature, 100);
    armature->getAnimation()->play("circle");//action name

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章