code:
#include "EaseActionsTest.h"
#include "../testResource.h"

enum {
	kTagAction1 = 1,
	kTagAction2 = 2,
	kTagSlider = 1,
};

CCLayer* nextEaseAction();
CCLayer* backEaseAction();
CCLayer* restartEaseAction();

//------------------------------------------------------------------
//
// SpriteEase
//
//------------------------------------------------------------------

void SpriteEase::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0) );
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = (CCActionInterval*)CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, move_ease_out_back, NULL);

	CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
	a2->setTag(1);

	CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
	a1->setTag(1);

	CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
	a->setTag(1);

	schedule(schedule_selector(SpriteEase::testStopAction), 6);
}

void SpriteEase::testStopAction(ccTime dt)
{
	unschedule(schedule_selector(SpriteEase::testStopAction));
	m_tamara->stopActionByTag(1);
	m_kathia->stopActionByTag(1);
	m_grossini->stopActionByTag(1);
}

std::string SpriteEase::title()
{
	return "EaseIn - EaseOut - Stop";
}

//------------------------------------------------------------------
//
// SpriteEaseInOut
//
//------------------------------------------------------------------

void SpriteEaseInOut::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval*  move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
//	id move_back = move->reverse();

	CCActionInterval*  move_ease_inout1 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.0f);
	CCActionInterval*  move_ease_inout_back1 = move_ease_inout1->reverse();

	CCActionInterval*  move_ease_inout2 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval*  move_ease_inout_back2 = move_ease_inout2->reverse();

	CCActionInterval*  move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 4.0f);
	CCActionInterval*  move_ease_inout_back3 = move_ease_inout3->reverse();

	CCFiniteTimeAction*  seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL);
	CCFiniteTimeAction*  seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL);
	CCFiniteTimeAction*  seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL);

	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
}

std::string SpriteEaseInOut::title()
{
	return "EaseInOut and rates";
}

//------------------------------------------------------------------
//
// SpriteEaseExponential
//
//------------------------------------------------------------------

void SpriteEaseExponential::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = CCEaseExponentialIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseExponentialOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
}

std::string SpriteEaseExponential::title()
{
	return "ExpIn - ExpOut actions";
}
//------------------------------------------------------------------
//
// SpriteEaseExponentialInOut
//
//------------------------------------------------------------------

void SpriteEaseExponentialInOut::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease = CCEaseExponentialInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_back = move_ease->reverse();	//--> reverse()

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);

	this->positionForTwo();

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));

}

std::string SpriteEaseExponentialInOut::title()
{
	return "EaseExponentialInOut action";
}
//------------------------------------------------------------------
//
// SpriteEaseSine
//
//------------------------------------------------------------------

void SpriteEaseSine::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = CCEaseSineIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseSineOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));

}

std::string SpriteEaseSine::title()
{
	return "EaseSineIn - EaseSineOut";
}
//------------------------------------------------------------------
//
// SpriteEaseSineInOut
//
//------------------------------------------------------------------

void SpriteEaseSineInOut::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease = CCEaseSineInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_back = move_ease->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);

	this->positionForTwo();

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
}

std::string SpriteEaseSineInOut::title()
{
	return "EaseSineInOut action";
}
//------------------------------------------------------------------
//
// SpriteEaseElastic
//
//------------------------------------------------------------------

void SpriteEaseElastic::onEnter()
{
	EaseSpriteDemo::onEnter();
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = CCEaseElasticIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseElasticOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}

std::string SpriteEaseElastic::title()
{
	return "Elastic In - Out actions";
}

//------------------------------------------------------------------
//
// SpriteEaseElasticInOut
//
//------------------------------------------------------------------

void SpriteEaseElasticInOut::onEnter()
{
	EaseSpriteDemo::onEnter();

	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));

	CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.3f);
	CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();

	CCActionInterval* move_ease_inout2 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.45f);
	CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse();

	CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.6f);
	CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, move_ease_inout_back1, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, move_ease_inout_back2, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL);

	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}

std::string SpriteEaseElasticInOut::title()
{
	return "EaseElasticInOut action";
}

//------------------------------------------------------------------
//
// SpriteEaseBounce
//
//------------------------------------------------------------------

void SpriteEaseBounce::onEnter()
{
	EaseSpriteDemo::onEnter();
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = CCEaseBounceIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseBounceOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}

std::string SpriteEaseBounce::title()
{
	return "Bounce In - Out actions";
}

//------------------------------------------------------------------
//
// SpriteEaseBounceInOut
//
//------------------------------------------------------------------

void SpriteEaseBounceInOut::onEnter()
{
	EaseSpriteDemo::onEnter();

		CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease = CCEaseBounceInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_back = move_ease->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);

	this->positionForTwo();

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
}

std::string SpriteEaseBounceInOut::title()
{
	return "EaseBounceInOut action";
}

//------------------------------------------------------------------
//
// SpriteEaseBack
//
//------------------------------------------------------------------

void SpriteEaseBack::onEnter()
{
	EaseSpriteDemo::onEnter();
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease_in = CCEaseBackIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();

	CCActionInterval* move_ease_out = CCEaseBackOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_out, move_ease_out_back, NULL);

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
	m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3));
}

std::string SpriteEaseBack::title()
{
	return "Back In - Out actions";
}

//------------------------------------------------------------------
//
// SpriteEaseBackInOut
//
//------------------------------------------------------------------

void SpriteEaseBackInOut::onEnter()
{
	EaseSpriteDemo::onEnter();
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0));
	CCActionInterval* move_back = move->reverse();

	CCActionInterval* move_ease = CCEaseBackInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) );
	CCActionInterval* move_ease_back = move_ease->reverse();

	CCFiniteTimeAction* seq1 = CCSequence::actions( move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, move_ease_back, NULL);

	this->positionForTwo();

	m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1));
	m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2));
}

std::string SpriteEaseBackInOut::title()
{
	return "EaseBackInOut action";
}

//------------------------------------------------------------------
//
// SpeedTest
//
//------------------------------------------------------------------

void SpeedTest::onEnter()
{
	EaseSpriteDemo::onEnter();

	// rotate and jump
	CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4);
	CCActionInterval *jump2 = jump1->reverse();
	CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2);
	CCActionInterval *rot2 = rot1->reverse();

	CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL);
	CCFiniteTimeAction* seq3_2 = CCSequence::actions( rot1, rot2, NULL);
	CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL);
	CCSpeed* action = CCSpeed::actionWithAction(CCRepeatForever::actionWithAction((CCActionInterval*)spawn), 1.0f);
	action->setTag(kTagAction1);

	CCAction* action2 = (CCAction*)(action->copy()->autorelease());
	CCAction* action3 = (CCAction*)(action->copy()->autorelease());

	action2->setTag(kTagAction1);
	action3->setTag(kTagAction1);

	m_grossini->runAction( action2 );
	m_tamara->runAction( action3 );
	m_kathia->runAction( action );

	this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f];
}

void SpeedTest::altertime(ccTime dt)
{
	CCSpeed* action1 = (CCSpeed*)(m_grossini->getActionByTag(kTagAction1));
	CCSpeed* action2 = (CCSpeed*)(m_tamara->getActionByTag(kTagAction1));
	CCSpeed* action3 = (CCSpeed*)(m_kathia->getActionByTag(kTagAction1));

	action1->setSpeed( CCRANDOM_0_1() * 2 );
	action2->setSpeed( CCRANDOM_0_1() * 2 );
	action3->setSpeed( CCRANDOM_0_1() * 2 );
}

std::string SpeedTest::title()
{
	return "Speed action";
}

//------------------------------------------------------------------
//
// SchedulerTest
//
//------------------------------------------------------------------
void SchedulerTest::onEnter()
{
	EaseSpriteDemo::onEnter();

	// rotate and jump
	CCActionInterval* jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4);
	CCActionInterval* jump2 = jump1->reverse();
	CCActionInterval* rot1 = CCRotateBy::actionWithDuration(4, 360*2);
	CCActionInterval* rot2 = rot1->reverse();

	CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL);
	CCFiniteTimeAction* seq3_2 = CCSequence::actions( rot1, rot2, NULL);
	CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL);
	CCFiniteTimeAction* action = CCRepeatForever::actionWithAction((CCActionInterval*)spawn);

	CCRepeatForever* action2 = (CCRepeatForever*)(action->copy()->autorelease());
	CCRepeatForever* action3 = (CCRepeatForever*)(action->copy()->autorelease());

	m_grossini->runAction( CCSpeed::actionWithAction((CCActionInterval*)action, 0.5f) );
	m_tamara->runAction( CCSpeed::actionWithAction((CCActionInterval*)action2, 1.5f) );
	m_kathia->runAction( CCSpeed::actionWithAction((CCActionInterval*)action3, 1.0f) );

	CCParticleSystem* emitter = CCParticleFireworks::node();
    emitter->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
	addChild(emitter);

	//sliderCtl = [self sliderCtl];
	//[[[[Director sharedDirector] openGLView] window] addSubview: sliderCtl];
}

std::string SchedulerTest::title()
{
	return "Scheduler scaleTime Test";
}

//------------------------------------------------------------------
//
// EaseSpriteDemo
//
//------------------------------------------------------------------

enum
{
	IDC_NEXT = 100,
	IDC_BACK,
	IDC_RESTART
};

static int sceneIdx = -1;

#define MAX_LAYER	14

CCLayer* createEaseLayer(int nIndex)
{
	switch(nIndex)
	{
		case 0: return new SpriteEase();
		case 1: return new SpriteEaseInOut();
		case 2: return new SpriteEaseExponential();
		case 3: return new SpriteEaseExponentialInOut();
		case 4: return new SpriteEaseSine();
		case 5: return new SpriteEaseSineInOut();
		case 6: return new SpriteEaseElastic();
		case 7: return new SpriteEaseElasticInOut();
		case 8: return new SpriteEaseBounce();
		case 9: return new SpriteEaseBounceInOut();
		case 10: return new SpriteEaseBack();
		case 11: return new SpriteEaseBackInOut();
		case 12: return new SpeedTest();
		case 13: return new SchedulerTest();
	}

	return NULL;
}

CCLayer* nextEaseAction()
{
	sceneIdx++;
	sceneIdx = sceneIdx % MAX_LAYER;

	CCLayer* pLayer = createEaseLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

CCLayer* backEaseAction()
{
	sceneIdx--;
	int total = MAX_LAYER;
	if( sceneIdx < 0 )
		sceneIdx += total;

	CCLayer* pLayer = createEaseLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

CCLayer* restartEaseAction()
{
	CCLayer* pLayer = createEaseLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

EaseSpriteDemo::EaseSpriteDemo(void)
{
}

EaseSpriteDemo::~EaseSpriteDemo(void)
{
	m_grossini->release();
	m_tamara->release();
	m_kathia->release();
}

void EaseSpriteDemo::positionForTwo()
{
	m_grossini->setPosition( CCPointMake( 60, 120 ) );
	m_tamara->setPosition( CCPointMake( 60, 220) );
	m_kathia->setIsVisible(false);
}

std::string EaseSpriteDemo::title()
{
	return "No title";
}

void EaseSpriteDemo::onEnter()
{
	CCLayer::onEnter();

	// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
    m_grossini = CCSprite::spriteWithFile(s_pPathGrossini); m_grossini->retain();
	m_tamara = CCSprite::spriteWithFile(s_pPathSister1); m_tamara->retain();
	m_kathia = CCSprite::spriteWithFile(s_pPathSister2); m_kathia->retain();

	addChild( m_grossini, 3);
	addChild( m_kathia, 2);
	addChild( m_tamara, 1);

	CCSize s = CCDirector::sharedDirector()->getWinSize();

	m_grossini->setPosition( CCPointMake(60, 50) );
	m_kathia->setPosition( CCPointMake(60, 150) );
	m_tamara->setPosition( CCPointMake(60, 250) );

	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
	addChild(label);
	label->setPosition( CCPointMake(s.width/2, s.height-50) );

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(EaseSpriteDemo::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CCPointZero );
	item1->setPosition( CCPointMake( s.width/2 - 100,30) );
	item2->setPosition( CCPointMake( s.width/2, 30) );
	item3->setPosition( CCPointMake( s.width/2 + 100,30) );

	addChild(menu, 1);
}

void EaseSpriteDemo::restartCallback(CCObject* pSender)
{
	CCScene* s = new EaseActionsTestScene();//CCScene::node();
	s->addChild(restartEaseAction());

	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void EaseSpriteDemo::nextCallback(CCObject* pSender)
{
	CCScene* s = new EaseActionsTestScene();//CCScene::node();
	s->addChild( nextEaseAction() );
	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void EaseSpriteDemo::backCallback(CCObject* pSender)
{
	CCScene* s = new EaseActionsTestScene();//CCScene::node();
	s->addChild( backEaseAction() );
	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void EaseActionsTestScene::runThisTest()
{
    CCLayer* pLayer = nextEaseAction();
    addChild(pLayer);

    CCDirector::sharedDirector()->replaceScene(this);
}


code:
#ifndef _EASE_ACTIONS_TEST_H_
#define _EASE_ACTIONS_TEST_H_

////----#include "cocos2d.h"
#include "../testBasic.h"

using namespace cocos2d;

class EaseSpriteDemo : public CCLayer
{
protected:
	CCSprite*	m_grossini;
	CCSprite*	m_tamara;
	CCSprite*	m_kathia;

	std::string	m_strTitle;

public:
	EaseSpriteDemo(void);
	~EaseSpriteDemo(void);

	virtual std::string title();
	virtual void onEnter();

	void restartCallback(CCObject* pSender);
	void nextCallback(CCObject* pSender);
	void backCallback(CCObject* pSender);

	void positionForTwo();
};

class SpriteEase : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();

	void testStopAction(ccTime dt);
};

class SpriteEaseInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseExponential : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseExponentialInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseSine : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseSineInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseElastic : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseElasticInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseBounce : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseBounceInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseBack : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpriteEaseBackInOut : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class SpeedTest : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();

	void altertime(ccTime dt);
};

class SchedulerTest : public EaseSpriteDemo
{
public:
	void onEnter();
	virtual std::string title();
};

class EaseActionsTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

#endif

license: mit


code:
#include "EffectsAdvancedTest.h"

enum
{
	kTagTextLayer = 1,

	kTagSprite1 = 1,
	kTagSprite2 = 2,

	kTagBackground = 1,
	kTagLabel = 2,
};

//------------------------------------------------------------------
//
// Effect1
//
//------------------------------------------------------------------
void Effect1::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* target = getChildByTag(kTagBackground);

	// To reuse a grid the grid size and the grid type must be the same.
	// in this case:
	//     Lens3D is Grid3D and it's size is (15,10)
	//     Waves3D is Grid3D and it's size is (15,10)

	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCActionInterval* lens = CCLens3D::actionWithPosition(ccp(size.width/2,size.height/2), 240, ccg(15,10), 0.0f);
	CCActionInterval* waves = CCWaves3D::actionWithWaves(18, 15, ccg(15,10), 10);

	CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(1);
	CCActionInterval* delay = CCDelayTime::actionWithDuration(8);

	CCActionInterval* orbit = CCOrbitCamera::actionWithDuration(5, 1, 2, 0, 180, 0, -90);
	CCActionInterval* orbit_back = orbit->reverse();

	target->runAction( CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions( orbit, orbit_back, NULL) ) ) );
	target->runAction( CCSequence::actions(lens, delay, reuse, waves, NULL) );
}

std::string Effect1::title()
{
	return "Lens + Waves3d and OrbitCamera";
}

//------------------------------------------------------------------
//
// Effect2
//
//------------------------------------------------------------------
void Effect2::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* target = getChildByTag(kTagBackground);

	// To reuse a grid the grid size and the grid type must be the same.
	// in this case:
	//     ShakyTiles is TiledGrid3D and it's size is (15,10)
	//     Shuffletiles is TiledGrid3D and it's size is (15,10)
	//	   TurnOfftiles is TiledGrid3D and it's size is (15,10)
	CCActionInterval* shaky = CCShakyTiles3D::actionWithRange(4, false, ccg(15,10), 5);
	CCActionInterval* shuffle = CCShuffleTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnoff = CCTurnOffTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnon = turnoff->reverse();

	// reuse 2 times:
	//   1 for shuffle
	//   2 for turn off
	//   turnon tiles will use a new grid
	CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(2);

	CCActionInterval* delay = CCDelayTime::actionWithDuration(1);

//	id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
//	id orbit_back = [orbit reverse];
//
//	[target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]];
	target->runAction( (CCActionInterval *)(CCSequence::actions( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) );
}

std::string Effect2::title()
{
	return "ShakyTiles + ShuffleTiles + TurnOffTiles";
}

//------------------------------------------------------------------
//
// Effect3
//
//------------------------------------------------------------------
void Effect3::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* bg = getChildByTag(kTagBackground);
	CCNode* target1 = bg->getChildByTag(kTagSprite1);
	CCNode* target2 = bg->getChildByTag(kTagSprite2);

	CCActionInterval* waves = CCWaves::actionWithWaves(5, 20, true, false, ccg(15,10), 5);
	CCActionInterval* shaky = CCShaky3D::actionWithRange(4, false, ccg(15,10), 5);

	target1->runAction( CCRepeatForever::actionWithAction( waves ) );
	target2->runAction( CCRepeatForever::actionWithAction( shaky ) );

	// moving background. Testing issue #244
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, ccp(200,0) );
	bg->runAction(CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions(move, move->reverse(), NULL) ) ) );
}

std::string Effect3::title()
{
	return "Effects on 2 sprites";
}

//------------------------------------------------------------------
//
// Effect4
//
//------------------------------------------------------------------
void Effect4::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCActionInterval* lens = CCLens3D::actionWithPosition(ccp(100,180), 150, ccg(32,24), 10);
	//id move = [MoveBy::actionWithDuration:5 position:ccp(400,0)];

    /**
    @todo we only support CCNode run actions now.
    */
// 	CCActionInterval* move = CCJumpBy::actionWithDuration(5, ccp(380,0), 100, 4);
// 	CCActionInterval* move_back = move->reverse();
// 	CCActionInterval* seq = (CCActionInterval *)(CCSequence::actions( move, move_back, NULL));
//  CCActionManager::sharedManager()->addAction(seq, lens, false);

	runAction( lens );
}

std::string Effect4::title()
{
	return "Jumpy Lens3D";
}

//------------------------------------------------------------------
//
// Effect5
//
//------------------------------------------------------------------
void Effect5::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	//CCDirector::sharedDirector()->setProjection(CCDirectorProjection2D);

	CCActionInterval* effect = CCLiquid::actionWithWaves(1, 20, ccg(32,24), 2);

	CCActionInterval* stopEffect = (CCActionInterval *)( CCSequence::actions(
										 effect,
										 CCDelayTime::actionWithDuration(2),
										 CCStopGrid::action(),
					//					 [DelayTime::actionWithDuration:2],
					//					 [[effect copy] autorelease],
										 NULL) );

	CCNode* bg = getChildByTag(kTagBackground);
	bg->runAction(stopEffect);
}

std::string Effect5::title()
{
	return "Test Stop-Copy-Restar";
}

void Effect5::onExit()
{
	EffectAdvanceTextLayer::onExit();

	CCDirector::sharedDirector()->setProjection(CCDirectorProjection3D);
}

//------------------------------------------------------------------
//
// Effect5
//
//------------------------------------------------------------------
void Issue631::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCActionInterval* effect = (CCActionInterval*)(CCSequence::actions( CCDelayTime::actionWithDuration(2.0f), CCShaky3D::actionWithRange(16, false, ccg(5, 5), 5.0f), NULL));

	// cleanup
	CCNode* bg = getChildByTag(kTagBackground);
	removeChild(bg, true);

	// background
	CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4f(255,0,0,255) );
	addChild(layer, -10);
	CCSprite* sprite = CCSprite::spriteWithFile("Images/grossini.png");
	sprite->setPosition( ccp(50,80) );
	layer->addChild(sprite, 10);

	// foreground
	CCLayerColor* layer2 = CCLayerColor::layerWithColor(ccc4f( 0, 255,0,255 ) );
	CCSprite* fog = CCSprite::spriteWithFile("Images/Fog.png");

    ccBlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
	fog->setBlendFunc(bf);
	layer2->addChild(fog, 1);
	addChild(layer2, 1);

	layer2->runAction( CCRepeatForever::actionWithAction(effect) );
}

std::string Issue631::title()
{
	return "Testing Opacity";
}

std::string Issue631::subtitle()
{
	return "Effect image should be 100% opaque. Testing issue #631";
}

//------------------------------------------------------------------
//
// EffectAdvanceTextLayer
//
//------------------------------------------------------------------

enum
{
	IDC_NEXT = 100,
	IDC_BACK,
	IDC_RESTART
};

static int sceneIdx = -1;

#define MAX_LAYER	6

CCLayer* nextEffectAdvanceAction();
CCLayer* backEffectAdvanceAction();
CCLayer* restartEffectAdvanceAction();

CCLayer* createEffectAdvanceLayer(int nIndex)
{
	switch(nIndex)
	{
		case 0: return new Effect3();
		case 1: return new Effect2();
		case 2: return new Effect1();
		case 3: return new Effect4();
		case 4: return new Effect5();
		case 5: return new Issue631();
	}

	return NULL;
}

CCLayer* nextEffectAdvanceAction()
{
	sceneIdx++;
	sceneIdx = sceneIdx % MAX_LAYER;

	CCLayer* pLayer = createEffectAdvanceLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

CCLayer* backEffectAdvanceAction()
{
	sceneIdx--;
	int total = MAX_LAYER;
	if( sceneIdx < 0 )
		sceneIdx += total;

	CCLayer* pLayer = createEffectAdvanceLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

CCLayer* restartEffectAdvanceAction()
{
	CCLayer* pLayer = createEffectAdvanceLayer(sceneIdx);
	pLayer->autorelease();

	return pLayer;
}

void EffectAdvanceTextLayer::onEnter(void)
{
	CCLayer::onEnter();
	float x,y;

	CCSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;

	CCSprite *bg = CCSprite::spriteWithFile("Images/background3.png");
	addChild(bg, 0, kTagBackground);
	bg->setPosition( ccp(x/2,y/2) );

	CCSprite* grossini = CCSprite::spriteWithFile("Images/grossinis_sister2.png");
	bg->addChild(grossini, 1, kTagSprite1);
	grossini->setPosition( ccp(x/3.0f,200) );
	CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc_back = sc->reverse();
	grossini->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) );

	CCSprite* tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png");
	bg->addChild(tamara, 1, kTagSprite2);
	tamara->setPosition( ccp(2*x/3.0f,200) );
	CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc2_back = sc2->reverse();
	tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) );

	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28);

	label->setPosition( ccp(x/2,y-80) );
	addChild(label);
	label->setTag( kTagLabel );

	std::string strSubtitle = subtitle();
	if( ! strSubtitle.empty() )
	{
		CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
		addChild(l, 101);
		l->setPosition( ccp(size.width/2, size.height-80) );
	}

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CCPointZero );
	item1->setPosition( ccp( size.width/2 - 100,30) );
	item2->setPosition( ccp( size.width/2, 30) );
	item3->setPosition( ccp( size.width/2 + 100,30) );

	addChild(menu, 1);
}

EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)
{
}

std::string EffectAdvanceTextLayer::title()
{
	return "No title";
}

std::string EffectAdvanceTextLayer::subtitle()
{
	return "";
}

void EffectAdvanceTextLayer::restartCallback(CCObject* pSender)
{
	CCScene* s = new EffectAdvanceScene();
	s->addChild(restartEffectAdvanceAction());

	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void EffectAdvanceTextLayer::nextCallback(CCObject* pSender)
{
	CCScene* s = new EffectAdvanceScene();
	s->addChild( nextEffectAdvanceAction() );
	CCDirector::sharedDirector()->replaceScene(s);

    s->release();
}

void EffectAdvanceTextLayer::backCallback(CCObject* pSender)
{
	CCScene* s = new EffectAdvanceScene();
	s->addChild( backEffectAdvanceAction() );
	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void EffectAdvanceScene::runThisTest()
{
    CCLayer* pLayer = nextEffectAdvanceAction();

    addChild(pLayer);
    CCDirector::sharedDirector()->replaceScene(this);
}


code:
#ifndef _EFFECT_ADVANCED_TEST_H_
#define _EFFECT_ADVANCED_TEST_H_

#include "cocos2d.h"
#include "../testBasic.h"

class EffectAdvanceTextLayer: public CCLayer
{
protected:
    CCTextureAtlas* m_atlas;

	std::string	m_strTitle;

public:
	virtual void onEnter();
	~EffectAdvanceTextLayer(void);

	virtual std::string title();
	virtual std::string subtitle();

	void restartCallback(CCObject* pSender);
	void nextCallback(CCObject* pSender);
	void backCallback(CCObject* pSender);
};

class Effect1 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual std::string title();
};

class Effect2 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual std::string title();
};

class Effect3 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual std::string title();
};

class Effect4 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual std::string title();
};

class Effect5 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual void onExit();
	virtual std::string title();
};

class Issue631 : public EffectAdvanceTextLayer
{
public:
	virtual void onEnter();
	virtual std::string title();
	virtual std::string subtitle();
};

class EffectAdvanceScene : public TestScene
{
public:
    virtual void runThisTest();
};

#endif


code:
#include "EffectsTest.h"
#include "../testResource.h"

enum {
    kTagTextLayer = 1,

    kTagBackground = 1,
    kTagLabel = 2,
};

static int actionIdx=0;
static std::string effectsList[] =
{
	"Shaky3D",
	"Waves3D",
	"FlipX3D",
	"FlipY3D",
	"Lens3D",
	"Ripple3D",
	"Liquid",
	"Waves",
	"Twirl",
	"ShakyTiles3D",
	"ShatteredTiles3D",
	"ShuffleTiles",
	"FadeOutTRTiles",
	"FadeOutBLTiles",
	"FadeOutUpTiles",
	"FadeOutDownTiles",
	"TurnOffTiles",
	"WavesTiles3D",
	"JumpTiles3D",
	"SplitRows",
	"SplitCols",
	"PageTurn3D",
};

class Shaky3DDemo : public CCShaky3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCShaky3D::actionWithRange(5, true, ccg(15,10), t);
	}
};

class Waves3DDemo : public CCWaves3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCWaves3D::actionWithWaves(5, 40, ccg(15,10), t);
	}
};

class FlipX3DDemo : public CCFlipX3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFlipX3D* flipx  = CCFlipX3D::actionWithDuration(t);
		CCActionInterval* flipx_back = flipx->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(2);

		return (CCActionInterval*)(CCSequence::actions(flipx, delay, flipx_back, NULL));
	}
};

class FlipY3DDemo : public CCFlipY3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFlipY3D* flipy  = CCFlipY3D::actionWithDuration(t);
		CCActionInterval* flipy_back = flipy->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(2);

		return (CCActionInterval*)(CCSequence::actions(flipy, delay, flipy_back, NULL));
	}
};

class Lens3DDemo : public CCLens3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		return CCLens3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, ccg(15,10), t);
	}
};

class Ripple3DDemo : public CCRipple3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		return CCRipple3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, 4, 160, ccg(32,24), t);
	}
};

class LiquidDemo : public CCLiquid
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCLiquid::actionWithWaves(4, 20, ccg(16,12), t);
	}
};

class WavesDemo : public CCWaves
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCWaves::actionWithWaves(4, 20, true, true, ccg(16,12), t);
	}
};

class TwirlDemo : public CCTwirl
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		return CCTwirl::actionWithPosition(CCPointMake(size.width/2, size.height/2), 1, 2.5f, ccg(12,8), t);
	}
};

class ShakyTiles3DDemo : public CCShakyTiles3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCShakyTiles3D::actionWithRange(5, true, ccg(16,12), t) ;
	}
};

class ShatteredTiles3DDemo : public CCShatteredTiles3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCShatteredTiles3D::actionWithRange(5, true, ccg(16,12), t);
	}
};

class ShuffleTilesDemo : public CCShuffleTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCShuffleTiles* shuffle = CCShuffleTiles::actionWithSeed(25, ccg(16,12), t);
		CCActionInterval* shuffle_back = shuffle->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(2);

		return (CCActionInterval*)(CCSequence::actions(shuffle, delay, shuffle_back, NULL));
	}
};

class FadeOutTRTilesDemo : public CCFadeOutTRTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFadeOutTRTiles* fadeout = CCFadeOutTRTiles::actionWithSize(ccg(16,12), t);
		CCActionInterval* back = fadeout->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);

		return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
	}
};

class FadeOutBLTilesDemo : public CCFadeOutBLTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFadeOutBLTiles* fadeout = CCFadeOutBLTiles::actionWithSize(ccg(16,12), t);
		CCActionInterval* back = fadeout->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);

		return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
	}
};

class FadeOutUpTilesDemo : public CCFadeOutUpTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFadeOutUpTiles* fadeout = CCFadeOutUpTiles::actionWithSize(ccg(16,12), t);
		CCActionInterval* back = fadeout->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);

		return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
	}
};

class FadeOutDownTilesDemo : public CCFadeOutDownTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCFadeOutDownTiles* fadeout = CCFadeOutDownTiles::actionWithSize(ccg(16,12), t);
		CCActionInterval* back = fadeout->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);

		return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
	}
};

class TurnOffTilesDemo : public CCTurnOffTiles
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCTurnOffTiles* fadeout = CCTurnOffTiles::actionWithSeed(25, ccg(48,32) , t);
		CCActionInterval* back = fadeout->reverse();
		CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f);

		return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL));
	}
};

class WavesTiles3DDemo : public CCWavesTiles3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCWavesTiles3D::actionWithWaves(4, 120, ccg(15,10), t);
	}
};

class JumpTiles3DDemo : public CCJumpTiles3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		return CCJumpTiles3D::actionWithJumps(2, 30, ccg(15,10), t);
	}
};

class SplitRowsDemo : public CCSplitRows
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCSplitRows::actionWithRows(9, t);
	}
};

class SplitColsDemo : public CCSplitCols
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
		return CCSplitCols::actionWithCols(9, t);
	}
};

class PageTurn3DDemo : public CCPageTurn3D
{
public:
	static CCActionInterval* actionWithDuration(ccTime t)
	{
        CCDirector::sharedDirector()->setDepthTest(true);
		return CCPageTurn3D::actionWithSize(ccg(15,10), t);
	}
};

//------------------------------------------------------------------
//
// TextLayer
//
//------------------------------------------------------------------
#define MAX_LAYER	22

CCActionInterval* createEffect(int nIndex, ccTime t)
{

    CCDirector::sharedDirector()->setDepthTest(false);

	switch(nIndex)
	{
		case 0: return Shaky3DDemo::actionWithDuration(t);
		case 1: return Waves3DDemo::actionWithDuration(t);
		case 2: return FlipX3DDemo::actionWithDuration(t);
		case 3: return FlipY3DDemo::actionWithDuration(t);
		case 4: return Lens3DDemo::actionWithDuration(t);
		case 5: return Ripple3DDemo::actionWithDuration(t);
		case 6: return LiquidDemo::actionWithDuration(t);
		case 7: return WavesDemo::actionWithDuration(t);
		case 8: return TwirlDemo::actionWithDuration(t);
		case 9: return ShakyTiles3DDemo::actionWithDuration(t);
		case 10: return ShatteredTiles3DDemo::actionWithDuration(t);
		case 11: return ShuffleTilesDemo::actionWithDuration(t);
		case 12: return FadeOutTRTilesDemo::actionWithDuration(t);
		case 13: return FadeOutBLTilesDemo::actionWithDuration(t);
		case 14: return FadeOutUpTilesDemo::actionWithDuration(t);
		case 15: return FadeOutDownTilesDemo::actionWithDuration(t);
		case 16: return TurnOffTilesDemo::actionWithDuration(t);
		case 17: return WavesTiles3DDemo::actionWithDuration(t);
		case 18: return JumpTiles3DDemo::actionWithDuration(t);
		case 19: return SplitRowsDemo::actionWithDuration(t);
		case 20: return SplitColsDemo::actionWithDuration(t);
		case 21: return PageTurn3DDemo::actionWithDuration(t);
	}

	return NULL;
}

CCActionInterval* getAction()
{
	CCActionInterval* pEffect = createEffect(actionIdx, 3);

	return pEffect;
}

void EffectTestScene::runThisTest()
{
    addChild(TextLayer::node());
    CCDirector::sharedDirector()->replaceScene(this);
}

#define SID_RESTART		1

TextLayer::TextLayer(void)
{
	initWithColor( ccc4f(32,32,32,255) );

	float x,y;

	CCSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;

	CCNode* node = CCNode::node();
	CCActionInterval* effect = getAction();
	node->runAction(effect)
		;
	addChild(node, 0, kTagBackground);

	CCSprite *bg = CCSprite::spriteWithFile(s_back3);
	node->addChild(bg, 0);
	bg->setAnchorPoint( CCPointZero );

	CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2);
	node->addChild(grossini, 1);
	grossini->setPosition( CCPointMake(x/3,y/2) );
	CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc_back = sc->reverse();
	grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) );

	CCSprite* tamara = CCSprite::spriteWithFile(s_pPathSister1);
	node->addChild(tamara, 1);
	tamara->setPosition( CCPointMake(2*x/3,y/2) );
	CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc2_back = sc2->reverse();
	tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL))) );

	CCLabelTTF* label = CCLabelTTF::labelWithString((effectsList[actionIdx]).c_str(), "Marker Felt", 32);

	label->setPosition( CCPointMake(x/2,y-80) );
	addChild(label);
	label->setTag( kTagLabel );

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CCPointZero );
	item1->setPosition( CCPointMake( size.width/2 - 100,30) );
	item2->setPosition( CCPointMake( size.width/2, 30) );
	item3->setPosition( CCPointMake( size.width/2 + 100,30) );

	addChild(menu, 1);

	schedule( schedule_selector(TextLayer::checkAnim) );
}

void TextLayer::checkAnim(ccTime dt)
{
	CCNode* s2 = getChildByTag(kTagBackground);
	if ( s2->numberOfRunningActions() == 0 && s2->getGrid() != NULL)
		s2->setGrid(NULL);;
}

TextLayer::~TextLayer(void)
{
}

TextLayer* TextLayer::node()
{
	TextLayer* pLayer = new TextLayer();
	pLayer->autorelease();

	return pLayer;
}

void TextLayer::onEnter()
{
	CCLayer::onEnter();
}

void TextLayer::newOrientation()
{
	ccDeviceOrientation orientation = CCDirector::sharedDirector()->getDeviceOrientation();
	switch (orientation)
	{
		case CCDeviceOrientationLandscapeLeft:
			orientation = CCDeviceOrientationPortrait;
			break;
		case CCDeviceOrientationPortrait:
			orientation = CCDeviceOrientationLandscapeRight;
			break;
		case CCDeviceOrientationLandscapeRight:
			orientation = CCDeviceOrientationPortraitUpsideDown;
			break;
		case CCDeviceOrientationPortraitUpsideDown:
			orientation = CCDeviceOrientationLandscapeLeft;
			break;
	}

	CCDirector::sharedDirector()->setDeviceOrientation(orientation);
}

void TextLayer::newScene()
{
	CCScene* s = new EffectTestScene();
	CCNode* child = TextLayer::node();
	s->addChild(child);
	CCDirector::sharedDirector()->replaceScene(s);
    s->release();
}

void TextLayer::restartCallback(CCObject* pSender)
{
	/*newOrientation();*/
	newScene();
}

void TextLayer::nextCallback(CCObject* pSender)
{
    // update the action index
    actionIdx++;
    actionIdx = actionIdx % MAX_LAYER;

	/*newOrientation();*/
	newScene();
}

void TextLayer::backCallback(CCObject* pSender)
{
    // update the action index
    actionIdx--;
    int total = MAX_LAYER;
    if( actionIdx < 0 )
        actionIdx += total;

	/*newOrientation();*/
	newScene();
}


code:
#ifndef _EFFECTS_TEST_H_
#define _EFFECTS_TEST_H_

#include "../testBasic.h"

class EffectTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

class TextLayer : public CCLayerColor
{
protected:
	//UxString	m_strTitle;

public:
	TextLayer(void);
	~TextLayer(void);

	void checkAnim(ccTime dt);

	virtual void onEnter();

	void restartCallback(CCObject* pSender);
	void nextCallback(CCObject* pSender);
	void backCallback(CCObject* pSender);

	void newOrientation();
	void newScene();

	static TextLayer* node();
};

#endif


code:
#include "ExtensionsTest.h"
#include "../testResource.h"
#include "NotificationCenterTest.h"

enum
{
    MAX_COUNT = 1,
    LINE_SPACE = 40,
    kItemTagBasic = 1000,
};

static const std::string testsName[MAX_COUNT] =
{
    "NotificationCenterTest"
};

////////////////////////////////////////////////////////
//
// ExtensionsMainLayer
//
////////////////////////////////////////////////////////
void ExtensionsMainLayer::onEnter()
{
    CCLayer::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenu* pMenu = CCMenu::menuWithItems(NULL);
    pMenu->setPosition( CCPointZero );
    CCMenuItemFont::setFontName("Arial");
    CCMenuItemFont::setFontSize(24);
    for (int i = 0; i < MAX_COUNT; ++i)
    {
        CCMenuItemFont* pItem = CCMenuItemFont::itemFromString(testsName[i].c_str(), this,
                                                    menu_selector(ExtensionsMainLayer::menuCallback));
        pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
        pMenu->addChild(pItem, kItemTagBasic + i);
    }

    addChild(pMenu);
}

void ExtensionsMainLayer::menuCallback(CCObject* pSender)
{
    CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
    int nIndex = pItem->getZOrder() - kItemTagBasic;

    switch (nIndex)
    {
    case 0:
        runNotificationCenterTest();
        break;
    default:
        break;
    }
}

////////////////////////////////////////////////////////
//
// ExtensionsTestScene
//
////////////////////////////////////////////////////////

void ExtensionsTestScene::runThisTest()
{
    CCLayer* pLayer = new ExtensionsMainLayer();
    addChild(pLayer);
    pLayer->release();

    CCDirector::sharedDirector()->replaceScene(this);
}


code:
#ifndef __EXTENSIONS_TEST_H__
#define __EXTENSIONS_TEST_H__

#include "../testBasic.h"

class ExtensionsMainLayer : public CCLayer
{
public:
    virtual void onEnter();
    void menuCallback(CCObject* pSender);
};

class ExtensionsTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

#endif /* __EXTENSIONS_TEST_H__ */


code:
#include "NotificationCenterTest.h"
#include "ExtensionsTest.h"

#define kTagLight 100
#define kTagConnect 200

#define MSG_SWITCH_STATE  "SwitchState"

USING_NS_CC;

class Light : public CCSprite
{
public:
    Light();
    ~Light();

    static Light* lightWithFile(const char* name);

    void setIsConnectToSwitch(bool bConnectToSwitch);
    void switchStateChanged(CCObject* obj);
    void updateLightState();

private:
    bool m_bConnected;
    static bool s_bSwitchOn;
};

bool Light::s_bSwitchOn = false;

Light::Light()
    : m_bConnected(false)
{}

Light::~Light()
{
    CCNotificationCenter::sharedNotifCenter()->removeObserver(this, MSG_SWITCH_STATE);
}

Light* Light::lightWithFile(const char* name)
{
    Light* pLight = new Light();
    pLight->initWithFile(name);
    pLight->autorelease();
    return pLight;
}

void Light::setIsConnectToSwitch(bool bConnectToSwitch)
{
    m_bConnected = bConnectToSwitch;
    if (m_bConnected)
    {
        CCNotificationCenter::sharedNotifCenter()->addObserver(this, callfuncO_selector(Light::switchStateChanged), MSG_SWITCH_STATE, NULL);
    }
    else
    {
        CCNotificationCenter::sharedNotifCenter()->removeObserver(this, MSG_SWITCH_STATE);
    }
    updateLightState();
}

void Light::switchStateChanged(CCObject* obj)
{
    int index = (int)obj;
    s_bSwitchOn = index == 0 ? false : true;
    updateLightState();
}

void Light::updateLightState()
{
    if (s_bSwitchOn && m_bConnected)
    {
        this->setOpacity(255);
    }
    else
    {
        this->setOpacity(50);
    }
}

NotificationCenterTest::NotificationCenterTest()
: m_bShowImage(false)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemFont* pBackItem = CCMenuItemFont::itemFromString("Back", this,
        menu_selector(NotificationCenterTest::toExtensionsMainLayer));
    pBackItem->setPosition(ccp(s.width - 50, 25));
    CCMenu* pBackMenu = CCMenu::menuWithItems(pBackItem, NULL);
    pBackMenu->setPosition( CCPointZero );
    addChild(pBackMenu);

    CCLabelTTF *label1 = CCLabelTTF::labelWithString("switch off", "Marker Felt", 26);
    CCLabelTTF *label2 = CCLabelTTF::labelWithString("switch on", "Marker Felt", 26);
    CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
    CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
    CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
    // turn on
    item->setSelectedIndex(1);
    CCMenu *menu = CCMenu::menuWithItems(item, NULL);
    menu->setPosition(ccp(s.width/2+100, s.height/2));
    addChild(menu);

    CCMenu *menuConnect = CCMenu::menuWithItems(NULL);
    menuConnect->setPosition(CCPointZero);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(ccp(100, s.height/4*i));
        addChild(light);

        CCLabelTTF *label1 = CCLabelTTF::labelWithString("not connected", "Marker Felt", 26);
        CCLabelTTF *label2 = CCLabelTTF::labelWithString("connected", "Marker Felt", 26);
        CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
        CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
        CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
        item->setTag(kTagConnect+i);
        item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    CCNotificationCenter::sharedNotifCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)item->getSelectedIndex());
}

void NotificationCenterTest::toExtensionsMainLayer(cocos2d::CCObject* sender)
{
    ExtensionsTestScene* pScene = new ExtensionsTestScene();
    pScene->runThisTest();
    pScene->release();
}

void NotificationCenterTest::toggleSwitch(CCObject *sender)
{
    CCMenuItemToggle* item = (CCMenuItemToggle*)sender;
    int index = item->getSelectedIndex();
    CCNotificationCenter::sharedNotifCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)index);
}

void NotificationCenterTest::connectToSwitch(CCObject *sender)
{
    CCMenuItemToggle* item = (CCMenuItemToggle*)sender;
    bool bConnected = item->getSelectedIndex() == 0 ? false : true;
    Light* pLight = (Light*)this->getChildByTag(item->getTag()-kTagConnect+kTagLight);
    pLight->setIsConnectToSwitch(bConnected);
}

void runNotificationCenterTest()
{
    CCScene* pScene = CCScene::node();
    NotificationCenterTest* pLayer = new NotificationCenterTest();
    pScene->addChild(pLayer);
    CCDirector::sharedDirector()->replaceScene(pScene);
    pLayer->release();
}


code:
#ifndef __NOTIFICATIONCENTERTEST_H__
#define __NOTIFICATIONCENTERTEST_H__

#include "cocos2d.h"
#include "ExtensionsTest.h"

class NotificationCenterTest : public cocos2d::CCLayer
{
public:
    NotificationCenterTest();
    void toExtensionsMainLayer(cocos2d::CCObject* sender);
    void toggleSwitch(cocos2d::CCObject *sender);
    void connectToSwitch(cocos2d::CCObject *sender);
private:
    bool m_bShowImage;
};

void runNotificationCenterTest();

#endif /* __NOTIFICATIONCENTERTEST_H__ */


code:
#include "FontTest.h"
#include "../testResource.h"

enum {
	kTagLabel1,
	kTagLabel2,
	kTagLabel3,
	kTagLabel4,
};

static int fontIdx = 0;

static std::string fontList[] =
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    "American Typewriter",
	"Marker Felt",
#endif
	"fonts/A Damn Mess.ttf",
	"fonts/Abberancy.ttf",
	"fonts/Abduction.ttf",
	"fonts/Paint Boy.ttf",
	"fonts/Schwarzwald Regular.ttf",
	"fonts/Scissor Cuts.ttf",
};

static const char* nextAction(void)
{
	fontIdx++;
	fontIdx = fontIdx % (sizeof(fontList) / sizeof(fontList[0]));
	return fontList[fontIdx].c_str();
}

static const char* backAction(void)
{
	fontIdx--;
	if (fontIdx < 0)
	{
		fontIdx += (sizeof(fontList) / sizeof(fontList[0]));
	}

	return fontList[fontIdx].c_str();
}

static const char* restartAction(void)
{
	return fontList[fontIdx].c_str();
}

FontTest::FontTest()
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback));
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback));
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback));

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
	menu->setPosition(CCPointZero);
	item1->setPosition(ccp(size.width/2 - 100,30));
	item2->setPosition(ccp(size.width/2, 30));
	item3->setPosition(ccp(size.width/2 + 100,30));
	addChild(menu, 1);

    showFont(restartAction());
}

void FontTest::showFont(const char *pFont)
{
	removeChildByTag(kTagLabel1, true);
	removeChildByTag(kTagLabel2, true);
	removeChildByTag(kTagLabel3, true);
	removeChildByTag(kTagLabel4, true);

	CCSize s = CCDirector::sharedDirector()->getWinSize();

	CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24);
	CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, pFont, 32);
	CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, pFont, 32);
	CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), CCTextAlignmentRight, pFont, 32);

	top->setPosition(ccp(s.width/2, 250));
	left->setPosition(ccp(s.width/2, 200));
	center->setPosition(ccp(s.width/2, 150));
	right->setPosition(ccp(s.width/2, 100));

	addChild(left, 0, kTagLabel1);
	addChild(right, 0, kTagLabel2);
	addChild(center, 0, kTagLabel3);
	addChild(top, 0, kTagLabel4);
}

void FontTest::backCallback(CCObject* pSender)
{
	showFont(backAction());
}

void FontTest::nextCallback(CCObject* pSender)
{
	showFont(nextAction());
}

std::string FontTest::title()
{
	return "Font test";
}

void FontTest::restartCallback(CCObject* pSender)
{
	showFont(restartAction());
}

///---------------------------------------
//
// DirectorTestScene
//
///---------------------------------------
void FontTestScene::runThisTest()
{
	CCLayer* pLayer = FontTest::node();
	addChild(pLayer);

	CCDirector::sharedDirector()->replaceScene(this);
}


code:
#ifndef _FONT_TEST_H_
#define _FONT_TEST_H_

#include "cocos2d.h"
#include "../testBasic.h"

class FontTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

class FontTest : public cocos2d::CCLayer
{
public:
	FontTest();
	void showFont(const char *pFont);

	void restartCallback(CCObject* pSender);
	void nextCallback(CCObject* pSender);
	void backCallback(CCObject* pSender);
	virtual std::string title();

	LAYER_NODE_FUNC(FontTest);
};

#endif // _FONT_TEST_H_


code:
#include "HiResTest.h"
#include "../testResource.h"

#define MAX_LAYERS          2;
static int sceneIdx = -1;

CCLayer* nextHiResAction();
CCLayer* restartHiResAction();
CCLayer* backHiResAction();

CCLayer* createHiResLayer(int idx)
{
    CCLayer* pLayer = NULL;

    switch (idx)
    {
    case 0:
        CCDirector::sharedDirector()->enableRetinaDisplay(false);
        pLayer = new HiResTest1();
        break;
    case 1:
        CCDirector::sharedDirector()->enableRetinaDisplay(true);
        pLayer = new HiResTest2();
        break;
    }

    return pLayer;
}

CCLayer* nextHiResAction()
{
    sceneIdx++;
    sceneIdx = sceneIdx % MAX_LAYERS;

    CCLayer* pLayer = createHiResLayer(sceneIdx);
    return pLayer;
}

CCLayer* restartHiResAction()
{
    CCLayer* pLayer = createHiResLayer(sceneIdx);
    return pLayer;
}

CCLayer* backHiResAction()
{
    sceneIdx--;
    if( sceneIdx < 0 )
        sceneIdx += MAX_LAYERS;

    CCLayer* pLayer = createHiResLayer(sceneIdx);
    return pLayer;
}

////////////////////////////////////
//
// HiResDemo
//
///////////////////////////////////
void HiResDemo::onEnter()
{
    CCLayer::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
    label->setPosition(ccp(s.width/2, s.height-50));
    addChild(label, 1);

    std::string sSubTitle = subtitle();
    if (sSubTitle.length())
    {
        CCLabelTTF *subLabel = CCLabelTTF::labelWithString(sSubTitle.c_str(), "Thonburi", 16);
        subLabel->setPosition(ccp(s.width/2, s.height-80));
        addChild(subLabel, 1);
    }

    CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) );
    CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) );

    CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

    menu->setPosition( CCPointZero );
    item1->setPosition( CCPointMake( s.width/2 - 100,30) );
    item2->setPosition( CCPointMake( s.width/2, 30) );
    item3->setPosition( CCPointMake( s.width/2 + 100,30) );

    addChild(menu, 1);
}

std::string HiResDemo::title()
{
    return "No title";
}

std::string HiResDemo::subtitle()
{
    return "";
}

void HiResDemo::restartCallback(CCObject* pSender)
{
    CCLayer* pLayer = restartHiResAction();

    if (pLayer)
    {
        pLayer->autorelease();
        CCScene* pScene = new HiResTestScene();
        pScene->addChild(pLayer);

        CCDirector::sharedDirector()->replaceScene(pScene);
        pScene->release();
    }
}

void HiResDemo::nextCallback(CCObject* pSender)
{
    CCLayer* pLayer = nextHiResAction();

    if (pLayer)
    {
        pLayer->autorelease();
        CCScene* pScene = new HiResTestScene();
        pScene->addChild(pLayer);

        CCDirector::sharedDirector()->replaceScene(pScene);
        pScene->release();
    }
}

void HiResDemo::backCallback(CCObject* pSender)
{
    CCLayer* pLayer = backHiResAction();

    if (pLayer)
    {
        pLayer->autorelease();
        CCScene* pScene = new HiResTestScene();
        pScene->addChild(pLayer);

        CCDirector::sharedDirector()->replaceScene(pScene);
        pScene->release();
    }
}

////////////////////////////////////
//
// HiResTest1
//
///////////////////////////////////
void HiResTest1::onEnter()
{

    HiResDemo::onEnter();

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png");
    addChild(sprite);
    sprite->setPosition(ccp(size.width/2, size.height/2));
}

std::string HiResTest1::title()
{
    return "High resolution image test";
}

std::string HiResTest1::subtitle()
{
    return "Image without high resolution resource";
}

////////////////////////////////////
//
// HiResTest2
//
///////////////////////////////////
void HiResTest2::onEnter()
{

    HiResDemo::onEnter();

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    CCSprite *sprite = CCSprite::spriteWithFile("Images/bugs/picture.png");
    addChild(sprite);
    sprite->setPosition(ccp(size.width/2, size.height/2));
}

std::string HiResTest2::title()
{
    return "High resolution image test";
}

std::string HiResTest2::subtitle()
{
    return "Image with high resolution resource";
}

////////////////////////////////////
//
// HiResTestScene
//
///////////////////////////////////
bool HiResTestScene::sm_bRitinaDisplay = false;

void HiResTestScene::runThisTest()
{
    sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();

    CCLayer* pLayer = nextHiResAction();
    addChild(pLayer);

    pLayer->release();
    CCDirector::sharedDirector()->replaceScene(this);
}

void HiResTestScene::MainMenuCallback(CCObject* pSender)
{
    CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay);
    TestScene::MainMenuCallback(pSender);
}


code:
#ifndef _HIRES_TEST_H_
#define _HIRES_TEST_H_

#include "../testBasic.h"

class HiResDemo : public CCLayer
{
public:
    virtual std::string title();
    virtual std::string subtitle();
    virtual void onEnter();

    void restartCallback(CCObject* pSender);
    void nextCallback(CCObject* pSender);
    void backCallback(CCObject* pSender);
};

class HiResTest1 : public HiResDemo
{
public:
    virtual void onEnter();

    virtual std::string title();
    virtual std::string subtitle();
};

class HiResTest2 : public HiResDemo
{
public:
    virtual void onEnter();

    virtual std::string title();
    virtual std::string subtitle();
};

class HiResTestScene : public TestScene
{
public:
    virtual void runThisTest();
    virtual void MainMenuCallback(CCObject* pSender);

    static bool sm_bRitinaDisplay;
};

#endif


code:
#include "IntervalTest.h"
#include "../testResource.h"

#define SID_STEP1	100
#define SID_STEP2	101
#define SID_STEP3	102

#define IDC_PAUSE	200

IntervalLayer::IntervalLayer()
{
	m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

	CCSize s = CCDirector::sharedDirector()->getWinSize();
	// sun
	CCParticleSystem* sun = CCParticleSun::node();
    sun->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
	sun->setPosition( CCPointMake(s.width-32,s.height-32) );

	sun->setTotalParticles(130);
	sun->setLife(0.6f);
	this->addChild(sun);

	// timers
    m_label0 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label1 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label2 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label3 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
    m_label4 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");

    scheduleUpdate();
	schedule(schedule_selector(IntervalLayer::step1));
	schedule(schedule_selector(IntervalLayer::step2), 0);
	schedule(schedule_selector(IntervalLayer::step3), 1.0f);
    schedule(schedule_selector(IntervalLayer::step4), 2.0f);

    m_label0->setPosition(CCPointMake(s.width*1/6, s.height/2));
	m_label1->setPosition(CCPointMake(s.width*2/6, s.height/2));
	m_label2->setPosition(CCPointMake(s.width*3/6, s.height/2));
	m_label3->setPosition(CCPointMake(s.width*4/6, s.height/2));
    m_label4->setPosition(CCPointMake(s.width*5/6, s.height/2));

    addChild(m_label0);
	addChild(m_label1);
	addChild(m_label2);
	addChild(m_label3);
    addChild(m_label4);

	// Sprite
	CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	sprite->setPosition( CCPointMake(40,50) );

	CCJumpBy* jump = CCJumpBy::actionWithDuration(3, CCPointMake(s.width-80,0), 50, 4);

	addChild(sprite);
	sprite->runAction( CCRepeatForever::actionWithAction(
															(CCActionInterval*)(CCSequence::actions(jump, jump->reverse(), NULL ))
														)
					 );
	// pause button
	CCMenuItem* item1 = CCMenuItemFont::itemFromString("Pause", this, menu_selector(IntervalLayer::onPause) );
	CCMenu* menu = CCMenu::menuWithItems(item1, NULL);
	menu->setPosition( CCPointMake(s.width/2, s.height-50) );

	addChild( menu );
}

IntervalLayer::~IntervalLayer()
{
    if(CCDirector::sharedDirector()->isPaused())
    {
        CCDirector::sharedDirector()->resume();
    }
}

void IntervalLayer::update(ccTime dt)
{
    m_time0 +=dt;
    char time[10] = {0};
    sprintf(time, "%2.1f", m_time0);
    m_label0->setString(time);
}

void IntervalLayer::onPause(CCObject* pSender)
{
	if(CCDirector::sharedDirector()->isPaused())
		CCDirector::sharedDirector()->resume();
	else
		CCDirector::sharedDirector()->pause();

}

void IntervalLayer::step1(ccTime dt)
{
	m_time1 +=dt;

    char str[10] = {0};
    sprintf(str, "%2.1f", m_time1);
	m_label1->setString( str );
}

void IntervalLayer::step2(ccTime dt)
{
	m_time2 +=dt;

    char str[10] = {0};
    sprintf(str, "%2.1f", m_time2);
    m_label2->setString( str );
}

void IntervalLayer::step3(ccTime dt)
{
	m_time3 +=dt;

    char str[10] = {0};
    sprintf(str, "%2.1f", m_time3);
    m_label3->setString( str );
}

void IntervalLayer::step4(ccTime dt)
{
    m_time4 +=dt;

    char str[10] = {0};
    sprintf(str, "%2.1f", m_time4);
    m_label4->setString( str );
}

void IntervalTestScene::runThisTest()
{
    CCLayer* pLayer = new IntervalLayer();
    addChild(pLayer);
    pLayer->release();

    CCDirector::sharedDirector()->replaceScene(this);
}


code:
#ifndef _INTERVAL_TEST_H_
#define _INTERVAL_TEST_H_

#include "../testBasic.h"

class IntervalLayer : public CCLayer
{
protected:
    CCLabelBMFont*	m_label0;
	CCLabelBMFont*	m_label1;
	CCLabelBMFont*	m_label2;
	CCLabelBMFont*	m_label3;
    CCLabelBMFont*	m_label4;

	ccTime		m_time0, m_time1, m_time2, m_time3, m_time4;

public:
	IntervalLayer(void);
    virtual ~IntervalLayer();
public:
	void onPause(CCObject* pSender);

	void step1(ccTime dt);
	void step2(ccTime dt);
	void step3(ccTime dt);
    void step4(ccTime dt);
    void update(ccTime dt);

	//CREATE_NODE(IntervalLayer);
};

class IntervalTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

#endif


code:
#include "KeypadTest.h"

KeypadTest::KeypadTest()
: m_bShow(true)
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* label = CCLabelTTF::labelWithString("Keypad Test", "Arial", 28);
	addChild(label, 0);
	label->setPosition( ccp(s.width/2, s.height-50) );

    setIsKeypadEnabled(true);

    // create a label to display the tip string
    m_pLabel = CCLabelTTF::labelWithString("Please press any key...", "Arial", 22);
    m_pLabel->setPosition(ccp(s.width / 2, s.height / 2));
	addChild(m_pLabel, 0);

    m_pLabel->retain();
}

KeypadTest::~KeypadTest()
{
	m_pLabel->release();
}

void KeypadTest::keyBackClicked()
{
	m_pLabel->setString("BACK clicked!");
}

void KeypadTest::keyMenuClicked()
{
	m_pLabel->setString("MENU clicked!");
}

void KeypadTestScene::runThisTest()
{
    CCLayer* pLayer = new KeypadTest();
    addChild(pLayer);

    CCDirector::sharedDirector()->replaceScene(this);
    pLayer->release();
}


code:
#ifndef _KEYPAD_TEST_H_
#define _KEYPAD_TEST_H_

#include "cocos2d.h"
#include "../testBasic.h"

class KeypadTest : public CCLayer
{
public:
	KeypadTest();
	~KeypadTest();

    virtual void keyBackClicked();
	virtual void keyMenuClicked();

private:
    CCLabelTTF*			m_pLabel;
    bool                m_bShow;
};

class KeypadTestScene : public TestScene
{
public:
    virtual void runThisTest();
};

#endif