axmol/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp

72 lines
1.8 KiB
C++
Raw Normal View History

2014-03-04 16:51:35 +08:00
#include "UILoadingBarTest_Editor.h"
2015-04-09 12:23:47 +08:00
USING_NS_CC;
using namespace cocos2d::ui;
UILoadingBarEditorTests::UILoadingBarEditorTests()
{
ADD_TEST_CASE(UILoadingBarTest_Editor);
}
2014-03-04 16:51:35 +08:00
// UILoadingBarTest_Editor
UILoadingBarTest_Editor::UILoadingBarTest_Editor()
2014-07-04 11:48:55 +08:00
:_count(0)
2014-03-04 16:51:35 +08:00
{
}
UILoadingBarTest_Editor::~UILoadingBarTest_Editor()
{
}
void UILoadingBarTest_Editor::configureGUIScene()
{
UIScene_Editor::configureGUIScene();
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
LoadingBar* loadingBar_left_to_right = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_856"));
loadingBar_left_to_right->setPercent(0);
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
loadingBar_right_to_left->setPercent(0);
}
bool UILoadingBarTest_Editor::init()
{
if (UIScene_Editor::init())
{
scheduleUpdate();
2014-03-04 16:51:35 +08:00
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILoadingBar/res.csb");
Node* child = node->getChildByTag(5);
child->removeFromParent();
_layout = static_cast<Layout*>(child);
_touchGroup->addChild(_layout);
this->configureGUIScene();
2014-03-04 16:51:35 +08:00
return true;
}
return false;
}
void UILoadingBarTest_Editor::update(float delta)
{
_count++;
if (_count > 100)
{
_count = 0;
}
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
LoadingBar* loadingBar_left_to_right = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_856"));
loadingBar_left_to_right->setPercent(_count);
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
loadingBar_right_to_left->setPercent(_count);
}