2012-04-19 14:35:52 +08:00
|
|
|
#include "ActionsEaseTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
enum {
|
2012-04-19 14:35:52 +08:00
|
|
|
kTagAction1 = 1,
|
|
|
|
kTagAction2 = 2,
|
|
|
|
kTagSlider = 1,
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextEaseAction();
|
|
|
|
Layer* backEaseAction();
|
|
|
|
Layer* restartEaseAction();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEase
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2013-06-19 06:06:53 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEase::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseIn::create(move->clone(), 2.5f);
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseOut::create(move->clone(), 2.5f);
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action *a2 = _grossini->runAction(RepeatForever::create(seq1));
|
2012-04-19 14:35:52 +08:00
|
|
|
a2->setTag(1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action *a1 = _tamara->runAction(RepeatForever::create(seq2));
|
2012-04-19 14:35:52 +08:00
|
|
|
a1->setTag(1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action *a = _kathia->runAction(RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
a->setTag(1);
|
|
|
|
|
2012-05-04 16:22:50 +08:00
|
|
|
schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void SpriteEase::testStopAction(float dt)
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
unschedule(schedule_selector(SpriteEase::testStopAction));
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->stopActionByTag(1);
|
|
|
|
_kathia->stopActionByTag(1);
|
|
|
|
_grossini->stopActionByTag(1);
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpriteEase::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseIn - EaseOut - Stop";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
// id move_back = move->reverse();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout1 = EaseInOut::create(move->clone(), 0.65f);
|
|
|
|
ActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout2 = EaseInOut::create(move->clone(), 1.35f);
|
|
|
|
ActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout3 = EaseInOut::create(move->clone(), 1.0f);
|
|
|
|
ActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create( move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create( move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create( move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction(RepeatForever::create(seq1));
|
|
|
|
_kathia->runAction(RepeatForever::create(seq2));
|
|
|
|
_grossini->runAction(RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseInOut and rates";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseExponential
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseExponential::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseExponentialIn::create(move->clone());
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseExponentialOut::create(move->clone());
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
|
|
|
_kathia->runAction( RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseExponential::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ExpIn - ExpOut actions";
|
|
|
|
}
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseExponentialInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseExponentialInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease = EaseExponentialInOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_back = move_ease->reverse(); //--> reverse()
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create( move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create( move_ease, delay, move_ease_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
this->positionForTwo();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseExponentialInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseExponentialInOut action";
|
|
|
|
}
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseSine
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseSine::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseSineIn::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseSineOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
|
|
|
_kathia->runAction( RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseSine::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseSineIn - EaseSineOut";
|
|
|
|
}
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseSineInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseSineInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease = EaseSineInOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_back = move_ease->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->positionForTwo();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
std::string SpriteEaseSineInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseSineInOut action";
|
|
|
|
}
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseElastic
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseElastic::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseElasticIn::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseElasticOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
|
|
|
_kathia->runAction( RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseElastic::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Elastic In - Out actions";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseElasticInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseElasticInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout1 = EaseElasticInOut::create(move->clone(), 0.3f);
|
|
|
|
ActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout2 = EaseElasticInOut::create(move->clone(), 0.45f);
|
|
|
|
ActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_inout3 = EaseElasticInOut::create(move->clone(), 0.6f);
|
|
|
|
ActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction( RepeatForever::create(seq1));
|
|
|
|
_kathia->runAction( RepeatForever::create(seq2));
|
|
|
|
_grossini->runAction( RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseElasticInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseElasticInOut action";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseBounce
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseBounce::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseBounceIn::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseBounceOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
|
|
|
_kathia->runAction( RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseBounce::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Bounce In - Out actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseBounceInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseBounceInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease = EaseBounceInOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_back = move_ease->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
this->positionForTwo();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseBounceInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseBounceInOut action";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseBack
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseBack::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_in = EaseBackIn::create(move->clone());
|
|
|
|
ActionInterval* move_ease_in_back = move_ease_in->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease_out = EaseBackOut::create( move->clone());
|
|
|
|
ActionInterval* move_ease_out_back = move_ease_out->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction(RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction(RepeatForever::create(seq2));
|
|
|
|
_kathia->runAction(RepeatForever::create(seq3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseBack::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Back In - Out actions";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpriteEaseBackInOut
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpriteEaseBackInOut::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_back = move->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* move_ease = EaseBackInOut::create(move->clone() );
|
|
|
|
ActionInterval* move_ease_back = move_ease->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
DelayTime *delay = DelayTime::create(0.25f);
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
|
|
|
Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
this->positionForTwo();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini->runAction( RepeatForever::create(seq1));
|
|
|
|
_tamara->runAction( RepeatForever::create(seq2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
|
|
|
|
std::string SpriteEaseBackInOut::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "EaseBackInOut action";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SpeedTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void SpeedTest::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
EaseSpriteDemo::onEnter();
|
2012-05-04 16:22:50 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Size s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// rotate and jump
|
2013-07-12 14:11:55 +08:00
|
|
|
ActionInterval *jump1 = JumpBy::create(4, Point(-s.width+80, 0), 100, 4);
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval *jump2 = jump1->reverse();
|
|
|
|
ActionInterval *rot1 = RotateBy::create(4, 360*2);
|
|
|
|
ActionInterval *rot2 = rot1->reverse();
|
|
|
|
|
|
|
|
Sequence* seq3_1 = Sequence::create(jump2, jump1, NULL);
|
|
|
|
Sequence* seq3_2 = Sequence::create( rot1, rot2, NULL);
|
|
|
|
Spawn* spawn = Spawn::create(seq3_1, seq3_2, NULL);
|
|
|
|
Speed* action = Speed::create(RepeatForever::create(spawn), 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
action->setTag(kTagAction1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Action* action2 = action->clone();
|
|
|
|
Action* action3 = action->clone();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
action2->setTag(kTagAction1);
|
|
|
|
action3->setTag(kTagAction1);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action2);
|
|
|
|
_tamara->runAction(action3);
|
|
|
|
_kathia->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f];
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void SpeedTest::altertime(float dt)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-09 05:38:14 +08:00
|
|
|
Speed* action1 = static_cast<Speed*>(_grossini->getActionByTag(kTagAction1));
|
|
|
|
Speed* action2 = static_cast<Speed*>(_tamara->getActionByTag(kTagAction1));
|
|
|
|
Speed* action3 = static_cast<Speed*>(_kathia->getActionByTag(kTagAction1));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-02-28 14:42:32 +08:00
|
|
|
action1->setSpeed( CCRANDOM_MINUS1_1() * 2 );
|
|
|
|
action2->setSpeed( CCRANDOM_MINUS1_1() * 2 );
|
|
|
|
action3->setSpeed( CCRANDOM_MINUS1_1() * 2 );
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpeedTest::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Speed action";
|
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// EaseSpriteDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
enum
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
IDC_NEXT = 100,
|
|
|
|
IDC_BACK,
|
|
|
|
IDC_RESTART
|
2010-08-25 17:02:58 +08:00
|
|
|
};
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
static int sceneIdx = -1;
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#define MAX_LAYER 13
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* createEaseLayer(int nIndex)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextEaseAction()
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx++;
|
|
|
|
sceneIdx = sceneIdx % MAX_LAYER;
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = createEaseLayer(sceneIdx);
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* backEaseAction()
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
sceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( sceneIdx < 0 )
|
|
|
|
sceneIdx += total;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = createEaseLayer(sceneIdx);
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* restartEaseAction()
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = createEaseLayer(sceneIdx);
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EaseSpriteDemo::EaseSpriteDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EaseSpriteDemo::~EaseSpriteDemo(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->release();
|
|
|
|
_tamara->release();
|
|
|
|
_kathia->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-08-25 17:02:58 +08:00
|
|
|
void EaseSpriteDemo::positionForTwo()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
_grossini->setPosition(Point(VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*1/5));
|
|
|
|
_tamara->setPosition(Point( VisibleRect::left().x+60, VisibleRect::bottom().y + VisibleRect::getVisibleRect().size.height*4/5));
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setVisible(false);
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string EaseSpriteDemo::title()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "No title";
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EaseSpriteDemo::onEnter()
|
|
|
|
{
|
2013-06-07 08:12:28 +08:00
|
|
|
BaseTest::onEnter();
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
|
2013-06-20 14:17:10 +08:00
|
|
|
_grossini = Sprite::create(s_pPathGrossini); _grossini->retain();
|
|
|
|
_tamara = Sprite::create(s_pPathSister1); _tamara->retain();
|
|
|
|
_kathia = Sprite::create(s_pPathSister2); _kathia->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
addChild( _grossini, 3);
|
|
|
|
addChild( _kathia, 2);
|
|
|
|
addChild( _tamara, 1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
_grossini->setPosition(Point(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5));
|
|
|
|
_kathia->setPosition(Point(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5));
|
|
|
|
_tamara->setPosition(Point(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5));
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void EaseSpriteDemo::restartCallback(Object* pSender)
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ActionsEaseTestScene();//CCScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(restartEaseAction());
|
2010-08-25 17:02:58 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2010-09-10 14:52:38 +08:00
|
|
|
s->release();
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void EaseSpriteDemo::nextCallback(Object* pSender)
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ActionsEaseTestScene();//CCScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild( nextEaseAction() );
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2010-09-10 14:52:38 +08:00
|
|
|
s->release();
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void EaseSpriteDemo::backCallback(Object* pSender)
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene* s = new ActionsEaseTestScene();//CCScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild( backEaseAction() );
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2010-09-10 14:52:38 +08:00
|
|
|
s->release();
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|
|
|
|
|
2012-03-20 18:07:42 +08:00
|
|
|
void ActionsEaseTestScene::runThisTest()
|
2010-08-25 17:02:58 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = nextEaseAction();
|
2010-08-25 17:02:58 +08:00
|
|
|
addChild(pLayer);
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(this);
|
2010-08-25 17:02:58 +08:00
|
|
|
}
|