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
|
|
|
|
|
|
|
CCLayer* nextAction();
|
|
|
|
CCLayer* backAction();
|
|
|
|
CCLayer* restartAction();
|
|
|
|
|
|
|
|
CCLayer* createLayer(int nIndex)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
CCLayer* nextAction()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx++;
|
|
|
|
sceneIdx = sceneIdx % MAX_LAYER;
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer* pLayer = createLayer(sceneIdx);
|
|
|
|
pLayer->autorelease();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCLayer* backAction()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( sceneIdx < 0 )
|
|
|
|
sceneIdx += total;
|
|
|
|
|
|
|
|
CCLayer* pLayer = createLayer(sceneIdx);
|
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
return pLayer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCLayer* restartAction()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer* pLayer = createLayer(sceneIdx);
|
|
|
|
pLayer->autorelease();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ProgressActionsTestScene::runThisTest()
|
|
|
|
{
|
|
|
|
addChild(nextAction());
|
|
|
|
CCDirector::sharedDirector()->replaceScene(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer::onEnter();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label, 1);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition( ccp(s.width/2, s.height-50) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
std::string strSubtitle = subtitle();
|
|
|
|
if( ! strSubtitle.empty() )
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(l, 1);
|
2012-10-23 17:48:50 +08:00
|
|
|
l->setPosition( ccp(s.width/2, s.height-80) );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) );
|
|
|
|
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) );
|
|
|
|
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
2012-06-11 18:25:57 +08:00
|
|
|
menu->setPosition(CCPointZero);
|
2012-10-23 17:48:50 +08:00
|
|
|
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu, 1);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(background, -10);
|
2012-03-19 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpriteDemo::restartCallback(CCObject* pSender)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene* s = new ProgressActionsTestScene();
|
|
|
|
s->addChild(restartAction());
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector::sharedDirector()->replaceScene(s);
|
2012-03-19 18:20:32 +08:00
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpriteDemo::nextCallback(CCObject* pSender)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene* s = new ProgressActionsTestScene();
|
|
|
|
s->addChild( nextAction() );
|
|
|
|
CCDirector::sharedDirector()->replaceScene(s);
|
2012-03-19 18:20:32 +08:00
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpriteDemo::backCallback(CCObject* pSender)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene* s = new ProgressActionsTestScene();
|
|
|
|
s->addChild( backAction() );
|
|
|
|
CCDirector::sharedDirector()->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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to1 = CCProgressTo::create(2, 100);
|
|
|
|
CCProgressTo *to2 = CCProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType( kCCProgressTimerTypeRadial );
|
|
|
|
addChild(left);
|
2012-10-23 17:48:50 +08:00
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction( CCRepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathBlock));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeRadial);
|
|
|
|
// Makes the ridial CCW
|
|
|
|
right->setReverseProgress(true);
|
|
|
|
addChild(right);
|
2012-10-23 17:48:50 +08:00
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction( CCRepeatForever::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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to1 = CCProgressTo::create(2, 100);
|
|
|
|
CCProgressTo *to2 = CCProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the left since the midpoint is 0 for the x
|
|
|
|
left->setMidpoint(ccp(0,0));
|
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
|
|
|
left->setBarChangeRate(ccp(1, 0));
|
|
|
|
addChild(left);
|
2012-10-23 17:48:50 +08:00
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction( CCRepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the left since the midpoint is 1 for the x
|
|
|
|
right->setMidpoint(ccp(1, 0));
|
|
|
|
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
|
|
|
right->setBarChangeRate(ccp(1, 0));
|
|
|
|
addChild(right);
|
2012-10-23 17:48:50 +08:00
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction( CCRepeatForever::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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to1 = CCProgressTo::create(2, 100);
|
|
|
|
CCProgressTo *to2 = CCProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeBar);
|
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
left->setMidpoint(ccp(0,0));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
left->setBarChangeRate(ccp(0, 1));
|
|
|
|
addChild(left);
|
2012-10-23 17:48:50 +08:00
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction( CCRepeatForever::create(to1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
right->setMidpoint(ccp(0, 1));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
right->setBarChangeRate(ccp(0, 1));
|
|
|
|
addChild(right);
|
2012-10-23 17:48:50 +08:00
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction( CCRepeatForever::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
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-03-19 18:20:32 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *action = CCProgressTo::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
|
|
|
|
*/
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathBlock));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeRadial);
|
|
|
|
addChild(left);
|
|
|
|
left->setMidpoint(ccp(0.25f, 0.75f));
|
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));
|
2012-03-19 18:20:32 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our image on the left should be a radial progress indicator, counter clockwise
|
|
|
|
*/
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathBlock));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeRadial);
|
|
|
|
right->setMidpoint(ccp(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);
|
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));
|
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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to = CCProgressTo::create(2, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeBar);
|
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
left->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
left->setBarChangeRate(ccp(1, 0));
|
|
|
|
addChild(left);
|
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
middle->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
middle->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
middle->setBarChangeRate(ccp(1,1));
|
|
|
|
addChild(middle);
|
|
|
|
middle->setPosition(ccp(s.width/2, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
right->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
right->setBarChangeRate(ccp(0, 1));
|
|
|
|
addChild(right);
|
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to = CCProgressTo::create(6, 100);
|
|
|
|
CCAction *tint = CCSequence::create(CCTintTo::create(1, 255, 0, 0),
|
|
|
|
CCTintTo::create(1, 0, 255, 0),
|
|
|
|
CCTintTo::create(1, 0, 0, 255),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction *fade = CCSequence::create(CCFadeTo::create(1.0f, 0),
|
|
|
|
CCFadeTo::create(1.0f, 255),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeBar);
|
|
|
|
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
left->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
left->setBarChangeRate(ccp(1, 0));
|
|
|
|
addChild(left);
|
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
|
|
|
left->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
left->addChild(CCLabelTTF::create("Tint", "Marker Felt", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
middle->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
middle->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
middle->setBarChangeRate(ccp(1, 1));
|
|
|
|
addChild(middle);
|
|
|
|
middle->setPosition(ccp(s.width/2, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
|
|
|
middle->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
middle->addChild(CCLabelTTF::create("Fade", "Marker Felt", 20.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
right->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
right->setBarChangeRate(ccp(0, 1));
|
|
|
|
addChild(right);
|
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));
|
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
right->addChild(CCLabelTTF::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();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTo *to = CCProgressTo::create(6, 100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *left = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_01.png"));
|
2012-04-19 14:35:52 +08:00
|
|
|
left->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
left->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
left->setBarChangeRate(ccp(1, 0));
|
|
|
|
addChild(left);
|
|
|
|
left->setPosition(ccp(100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *middle = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_02.png"));
|
2012-04-19 14:35:52 +08:00
|
|
|
middle->setType(kCCProgressTimerTypeBar);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
middle->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
middle->setBarChangeRate(ccp(1, 1));
|
|
|
|
addChild(middle);
|
|
|
|
middle->setPosition(ccp(s.width/2, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCProgressTimer *right = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_03.png"));
|
2012-04-19 14:35:52 +08:00
|
|
|
right->setType(kCCProgressTimerTypeRadial);
|
|
|
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
|
|
|
right->setMidpoint(ccp(0.5f, 0.5f));
|
|
|
|
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
|
|
|
right->setBarChangeRate(ccp(0, 1));
|
|
|
|
addChild(right);
|
|
|
|
right->setPosition(ccp(s.width-100, s.height/2));
|
2012-06-14 15:13:16 +08:00
|
|
|
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
|
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
|
|
|
}
|