//GameScene.cpp
#include "GameScene.h"
USING_NS_CC;
cocos2d::Scene* GameScene::createScene()
{
auto scene = Scene::create(); //创建一个场景
auto layer = GameScene::create(); //创建一个图层
scene->addChild(layer);
return scene;
}
//初始化当前的图层
bool GameScene::init()
{
if (!Layer::init()) //初始化父类
return false ;
//获取屏幕大小
Size visibleSize = Director::getInstance()->getVisibleSize();
//auto size = Director::getInstance()->getWinSize();
//创建进度条
auto progress1 = ProgressTo::create(3, 100);
auto progress2 = ProgressFromTo::create(3, 50, 100); //从30%到100%
auto progTime1 = ProgressTimer::create(Sprite::create( "Icon.png" ));
progTime1->setPosition(Vec2(visibleSize.width*0.4, visibleSize.height/2));
this ->addChild(progTime1);
auto progTime2 = ProgressTimer::create(Sprite::create( "Icon.png" ));
progTime2->setPosition(Vec2(visibleSize.width*0.6, visibleSize.height/2));
this ->addChild(progTime2);
//扇形
progTime1->setType(ProgressTimer::Type::RADIAL); //3.0版本改变处
//progTime->setMidpoint(Vec2(0.25f, 0.25f)); //改变扇形中心位置
progTime1->runAction(progress1);
//条形
progTime2->setType(ProgressTimer::Type::BAR);
//progTime2->setBarChangeRate(Vec2(1, 0)); //设置进度条为横向移动,纵向移动:Vec2(0,1)
//progTime2->setMidpoint(Vec2(0, 0)); //设置进度条从左往右移动,从右往左移动:Vec2(1,0)
progTime2->runAction(progress2);
return true ;
}
|