2012-03-19 18:20:32 +08:00
|
|
|
#include "ActionsProgressTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
|
|
|
static int sceneIdx = -1;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#define MAX_LAYER 7
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextAction();
|
|
|
|
Layer* backAction();
|
|
|
|
Layer* restartAction();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* createLayer(int nIndex)
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
switch(nIndex)
|
|
|
|
{
|
|
|
|
case 0: return new SpriteProgressToRadial();
|
|
|
|
case 1: return new SpriteProgressToHorizontal();
|
|
|
|
case 2: return new SpriteProgressToVertical();
|
|
|
|
case 3: return new SpriteProgressToRadialMidpointChanged();
|
|
|
|
case 4: return new SpriteProgressBarVarious();
|
|
|
|
case 5: return new SpriteProgressBarTintAndFade();
|
|
|
|
case 6: return new SpriteProgressWithSpriteFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextAction()
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx++;
|
|
|
|
sceneIdx = sceneIdx % MAX_LAYER;
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
Layer* layer = createLayer(sceneIdx);
|
|
|
|
layer->autorelease();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
return layer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* backAction()
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( sceneIdx < 0 )
|
|
|
|
sceneIdx += total;
|
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
Layer* layer = createLayer(sceneIdx);
|
|
|
|
layer->autorelease();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
return layer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* restartAction()
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2013-07-23 08:25:44 +08:00
|
|
|
Layer* layer = createLayer(sceneIdx);
|
|
|
|
layer->autorelease();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-07-23 08:25:44 +08:00
|
|
|
return layer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ProgressActionsTestScene::runThisTest()
|
|
|
|
{
|
|
|
|
addChild(nextAction());
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(this);
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
SpriteDemo::SpriteDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SpriteDemo::~SpriteDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteDemo::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ActionsProgressTest";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteDemo::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpriteDemo::onEnter()
|
|
|
|
{
|
2013-06-07 08:12:28 +08:00
|
|
|
BaseTest::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
LayerColor *background = LayerColor::create(Color4B(255,0,0,255));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(background, -10);
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void SpriteDemo::restartCallback(Object* pSender)
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ProgressActionsTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(restartAction());
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-03-19 18:20:32 +08:00
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void SpriteDemo::nextCallback(Object* pSender)
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ProgressActionsTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild( nextAction() );
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-03-19 18:20:32 +08:00
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void SpriteDemo::backCallback(Object* pSender)
|
2012-03-19 18:20:32 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ProgressActionsTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild( backAction() );
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-03-19 18:20:32 +08:00
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToRadial
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToRadial::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
|
|
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType( ProgressTimer::RADIAL );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction( RepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Makes the ridial CCW
|
|
|
|
right->setReverseProgress(true);
|
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction( RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressToRadial::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Radial";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToHorizontal
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SpriteProgressToHorizontal::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
|
|
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the left since the midpoint is 0 for the x
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setBarChangeRate(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction( RepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the left since the midpoint is 1 for the x
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setBarChangeRate(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction( RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressToHorizontal::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Horizontal";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToVertical
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToVertical::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
|
|
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setBarChangeRate(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction( RepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setBarChangeRate(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction( RepeatForever::create(to2));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressToVertical::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Vertical";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressToRadialMidpointChanged
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressToRadialMidpointChanged::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *action = ProgressTo::create(2, 100);
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2012-03-19 18:20:32 +08:00
|
|
|
* Our image on the left should be a radial progress indicator, clockwise
|
|
|
|
*/
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0.25f, 0.75f));
|
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(action->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our image on the left should be a radial progress indicator, counter clockwise
|
|
|
|
*/
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::RADIAL);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(0.75f, 0.25f));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2012-03-19 18:20:32 +08:00
|
|
|
* Note the reverse property (default=NO) is only added to the right image. That's how
|
|
|
|
* we get a counter clockwise progress.
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(action->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressToRadialMidpointChanged::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Radial w/ Different Midpoints";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressBarVarious
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressBarVarious::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to = ProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setBarChangeRate(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
middle->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setBarChangeRate(Point(1,1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setPosition(Point(s.width/2, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setBarChangeRate(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressBarVarious::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Bar Mid";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressBarTintAndFade
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressBarTintAndFade::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to = ProgressTo::create(6, 100);
|
|
|
|
auto tint = Sequence::create(TintTo::create(1, 255, 0, 0),
|
|
|
|
TintTo::create(1, 0, 255, 0),
|
|
|
|
TintTo::create(1, 0, 0, 255),
|
2013-06-19 06:06:53 +08:00
|
|
|
NULL);
|
2013-06-20 14:17:10 +08:00
|
|
|
auto fade = Sequence::create(FadeTo::create(1.0f, 0),
|
|
|
|
FadeTo::create(1.0f, 255),
|
2013-06-19 06:06:53 +08:00
|
|
|
NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setBarChangeRate(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
|
|
|
left->runAction(RepeatForever::create(tint->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
middle->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setBarChangeRate(Point(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setPosition(Point(s.width/2, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
|
|
|
middle->runAction(RepeatForever::create(fade->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setBarChangeRate(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
|
|
|
right->runAction(RepeatForever::create(tint->clone()));
|
|
|
|
right->runAction(RepeatForever::create(fade->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
right->addChild(LabelTTF::create("Tint and Fade", "Marker Felt", 20.0f));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressBarTintAndFade::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ProgressTo Bar Mid";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteProgressWithSpriteFrame
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SpriteProgressWithSpriteFrame::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTo *to = ProgressTo::create(6, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTimer *left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png"));
|
2013-07-25 15:11:36 +08:00
|
|
|
left->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setBarChangeRate(Point(1, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(left);
|
2013-07-12 14:11:55 +08:00
|
|
|
left->setPosition(Point(100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
left->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTimer *middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png"));
|
2013-07-25 15:11:36 +08:00
|
|
|
middle->setType(ProgressTimer::BAR);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setBarChangeRate(Point(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(middle);
|
2013-07-12 14:11:55 +08:00
|
|
|
middle->setPosition(Point(s.width/2, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
middle->runAction(RepeatForever::create(to->clone()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ProgressTimer *right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png"));
|
2013-07-25 15:11:36 +08:00
|
|
|
right->setType(ProgressTimer::RADIAL);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setMidpoint(Point(0.5f, 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setBarChangeRate(Point(0, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(right);
|
2013-07-12 14:11:55 +08:00
|
|
|
right->setPosition(Point(s.width-100, s.height/2));
|
2013-06-20 14:17:10 +08:00
|
|
|
right->runAction(RepeatForever::create(to->clone()));
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteProgressWithSpriteFrame::subtitle()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Progress With Sprite Frame";
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|