Add in. h
int _count; Layout* layout; void update(float delta);
Layout = Layout: create (); layout-> setSize (Size (widgetSize. width, widgetSize. height); // horizontal arrangement, similar to the linear layout in Android. // layout-> setLayoutType (LAYOUT_RELATIVE ); /* set the image as the background */layout-> setBackGroundImageScale9Enabled (true); layout-> setBackGroundImage ("green_edit.png"); layout-> setPosition (Point (0, 0 )); addChild (layout); LoadingBar * loadingBar = LoadingBar: create ("slider_bar_active_9patch.png"); loadingBar-> setTag (0); loadingBar-> setScale9Enabled (true ); loadingBar-> setCapInsets (Rect (0, 0, 0, 0); loadingBar-> setSize (Size (300, 23 )); // set the loading direction LoadingBarTypeRight right LoadingBarTypeLeft left loadingBar-> setDirection (LoadingBarTypeLeft); loadingBar-> setPosition (Point (widgetSize. width/2.0f, widgetSize. height/2.0f + loadingBar-> getSize (). height/4.0f); layout-> addChild (loadingBar); _ count = 0; scheduleUpdate ();
void LayoutTest::update(float delta){ _count++; if (_count > 100) { _count = 0; } LoadingBar* loadingBar = static_cast
(layout->getChildByTag(0)); loadingBar->setPercent(_count);}