请教一下,场景要如何获取控件

我用cocostudio做了一个场景,场景中只有一个UI做的图,我现在想获取UI上面的控件,应该怎么做…

你可以参考一下 https://github.com/chukong/CocoStudioSamples SampleSceneEditor 这个实例。

    CCComRender *pUIRender = static_cast<CCComRender*>(m_pGameScene->getChildByTag(10007)->getComponent("GUIComponent"));
    UILayer *pUILayer = static_cast<UILayer*>(pUIRender->getNode());
    UILoadingBar *pHPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("hp02_LoadingBar"));
    UILoadingBar *pMPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("mp02_LoadingBar"));

    pHPLoadingBar->setPercent(m_fPercentage);
    pMPLoadingBar->setPercent(m_fPercentage);