2012-04-19 14:35:52 +08:00
|
|
|
#include "ActionsTest.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "../testResource.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "cocos2d.h"
|
|
|
|
|
2013-06-07 08:12:28 +08:00
|
|
|
static std::function<CCLayer*()> createFunctions[] = {
|
2013-06-19 06:06:53 +08:00
|
|
|
|
2013-06-07 08:12:28 +08:00
|
|
|
CL(ActionManual),
|
|
|
|
CL(ActionMove),
|
|
|
|
CL(ActionRotate),
|
|
|
|
CL(ActionScale),
|
|
|
|
CL(ActionSkew),
|
|
|
|
CL(ActionRotationalSkew),
|
|
|
|
CL(ActionRotationalSkewVSStandardSkew),
|
|
|
|
CL(ActionSkewRotateScale),
|
|
|
|
CL(ActionJump),
|
|
|
|
CL(ActionCardinalSpline),
|
|
|
|
CL(ActionCatmullRom),
|
|
|
|
CL(ActionBezier),
|
|
|
|
CL(ActionBlink),
|
|
|
|
CL(ActionFade),
|
|
|
|
CL(ActionTint),
|
|
|
|
CL(ActionAnimate),
|
|
|
|
CL(ActionSequence),
|
|
|
|
CL(ActionSequence2),
|
|
|
|
CL(ActionRemoveSelf),
|
|
|
|
CL(ActionSpawn),
|
|
|
|
CL(ActionReverse),
|
|
|
|
CL(ActionDelayTime),
|
|
|
|
CL(ActionRepeat),
|
|
|
|
CL(ActionRepeatForever),
|
|
|
|
CL(ActionRotateToRepeat),
|
|
|
|
CL(ActionRotateJerk),
|
|
|
|
CL(ActionCallFunction),
|
|
|
|
CL(ActionCallFunc),
|
|
|
|
CL(ActionCallFuncND),
|
|
|
|
CL(ActionReverseSequence),
|
|
|
|
CL(ActionReverseSequence2),
|
|
|
|
CL(ActionOrbit),
|
|
|
|
CL(ActionFollow),
|
|
|
|
CL(ActionTargeted),
|
|
|
|
CL(ActionMoveStacked),
|
|
|
|
CL(ActionMoveJumpStacked),
|
|
|
|
CL(ActionMoveBezierStacked),
|
|
|
|
CL(ActionCardinalSplineStacked),
|
|
|
|
CL(ActionCatmullRomStacked),
|
|
|
|
CL(PauseResumeActions),
|
|
|
|
CL(Issue1305),
|
|
|
|
CL(Issue1305_2),
|
|
|
|
CL(Issue1288),
|
|
|
|
CL(Issue1288_2),
|
|
|
|
CL(Issue1327),
|
|
|
|
CL(Issue1398)
|
2013-02-28 14:42:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int sceneIdx=-1;
|
|
|
|
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
|
|
|
|
|
|
|
static CCLayer* nextAction()
|
|
|
|
{
|
|
|
|
sceneIdx++;
|
|
|
|
sceneIdx = sceneIdx % MAX_LAYER;
|
|
|
|
|
|
|
|
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
|
|
|
pLayer->init();
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
static CCLayer* backAction()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-02-28 14:42:45 +08:00
|
|
|
sceneIdx--;
|
|
|
|
int total = MAX_LAYER;
|
|
|
|
if( sceneIdx < 0 )
|
|
|
|
sceneIdx += total;
|
|
|
|
|
|
|
|
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
|
|
|
pLayer->init();
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
static CCLayer* restartAction()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-02-28 14:42:45 +08:00
|
|
|
CCLayer* pLayer = (createFunctions[sceneIdx])();
|
|
|
|
pLayer->init();
|
2012-04-19 14:35:52 +08:00
|
|
|
pLayer->autorelease();
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsTestScene::runThisTest()
|
|
|
|
{
|
2013-02-28 14:42:45 +08:00
|
|
|
sceneIdx = -1;
|
|
|
|
addChild(nextAction());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCDirector::sharedDirector()->replaceScene(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string ActionsDemo::title()
|
|
|
|
{
|
|
|
|
return "ActionsTest";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionsDemo::subtitle()
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::onEnter()
|
|
|
|
{
|
2013-06-07 08:12:28 +08:00
|
|
|
BaseTest::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini = CCSprite::create(s_pPathGrossini);
|
|
|
|
_grossini->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara = CCSprite::create(s_pPathSister1);
|
|
|
|
_tamara->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia = CCSprite::create(s_pPathSister2);
|
|
|
|
_kathia->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
addChild(_grossini, 1);
|
|
|
|
addChild(_tamara, 2);
|
|
|
|
addChild(_kathia, 3);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3));
|
|
|
|
_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3));
|
|
|
|
_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::onExit()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->release();
|
|
|
|
_tamara->release();
|
|
|
|
_kathia->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-07 08:12:28 +08:00
|
|
|
BaseTest::onExit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::restartCallback(CCObject* pSender)
|
|
|
|
{
|
|
|
|
CCScene* s = new ActionsTestScene();
|
2013-02-28 14:42:45 +08:00
|
|
|
s->addChild( restartAction() );
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector::sharedDirector()->replaceScene(s);
|
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::nextCallback(CCObject* pSender)
|
|
|
|
{
|
|
|
|
CCScene* s = new ActionsTestScene();
|
2013-02-28 14:42:45 +08:00
|
|
|
s->addChild( nextAction() );
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector::sharedDirector()->replaceScene(s);
|
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::backCallback(CCObject* pSender)
|
|
|
|
{
|
|
|
|
CCScene* s = new ActionsTestScene();
|
2013-02-28 14:42:45 +08:00
|
|
|
s->addChild( backAction() );
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector::sharedDirector()->replaceScene(s);
|
|
|
|
s->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::centerSprites(unsigned int numberOfSprites)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
if( numberOfSprites == 0 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setVisible(false);
|
|
|
|
_kathia->setVisible(false);
|
|
|
|
_grossini->setVisible(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else if ( numberOfSprites == 1 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setVisible(false);
|
|
|
|
_kathia->setVisible(false);
|
|
|
|
_grossini->setPosition(ccp(s.width/2, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else if( numberOfSprites == 2 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition( ccp(s.width/3, s.height/2));
|
|
|
|
_tamara->setPosition( ccp(2*s.width/3, s.height/2));
|
|
|
|
_grossini->setVisible(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else if( numberOfSprites == 3 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setPosition( ccp(s.width/2, s.height/2));
|
|
|
|
_tamara->setPosition( ccp(s.width/4, s.height/2));
|
|
|
|
_kathia->setPosition( ccp(3 * s.width/4, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsDemo::alignSpritesLeft(unsigned int numberOfSprites)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
if( numberOfSprites == 1 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setVisible(false);
|
|
|
|
_kathia->setVisible(false);
|
|
|
|
_grossini->setPosition(ccp(60, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else if( numberOfSprites == 2 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition( ccp(60, s.height/3));
|
|
|
|
_tamara->setPosition( ccp(60, 2*s.height/3));
|
|
|
|
_grossini->setVisible( false );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else if( numberOfSprites == 3 )
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setPosition( ccp(60, s.height/2));
|
|
|
|
_tamara->setPosition( ccp(60, 2*s.height/3));
|
|
|
|
_kathia->setPosition( ccp(60, s.height/3));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionManual
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionManual::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setScaleX( 2.5f);
|
|
|
|
_tamara->setScaleY( -1.0f);
|
|
|
|
_tamara->setPosition( ccp(100,70) );
|
|
|
|
_tamara->setOpacity( 128);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setRotation( 120);
|
|
|
|
_grossini->setPosition( ccp(s.width/2, s.height/2));
|
|
|
|
_grossini->setColor( ccc3( 255,0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition( ccp(s.width-100, s.height/2));
|
|
|
|
_kathia->setColor( ccBLUE);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionManual::subtitle()
|
|
|
|
{
|
|
|
|
return "Manual Transformation";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionMove
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionMove::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* actionTo = CCMoveTo::create(2, ccp(s.width-40, s.height-40));
|
|
|
|
CCActionInterval* actionBy = CCMoveBy::create(2, ccp(80,80));
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* actionByBack = actionBy->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( actionTo);
|
|
|
|
_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL));
|
|
|
|
_kathia->runAction(CCMoveTo::create(1, ccp(40,40)));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionMove::subtitle()
|
|
|
|
{
|
|
|
|
return "MoveTo / MoveBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionScale
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionScale::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-06-15 13:56:27 +08:00
|
|
|
CCActionInterval* actionTo = CCScaleTo::create(2.0f, 0.5f);
|
|
|
|
CCActionInterval* actionBy = CCScaleBy::create(2.0f, 1.0f, 10.0f);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* actionBy2 = CCScaleBy::create(2.0f, 5.0f, 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction( actionTo);
|
|
|
|
_tamara->runAction( CCSequence::create(actionBy, actionBy->reverse(), NULL));
|
|
|
|
_kathia->runAction( CCSequence::create(actionBy2, actionBy2->reverse(), NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionScale::subtitle()
|
|
|
|
{
|
|
|
|
return "ScaleTo / ScaleBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionSkew
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionSkew::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *actionTo = CCSkewTo::create(2, 37.2f, -37.2f);
|
|
|
|
CCActionInterval *actionToBack = CCSkewTo::create(2, 0, 0);
|
|
|
|
CCActionInterval *actionBy = CCSkewBy::create(2, 0.0f, -90.0f);
|
|
|
|
CCActionInterval *actionBy2 = CCSkewBy::create(2, 45.0f, 45.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval *actionByBack = actionBy->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(CCSequence::create(actionTo, actionToBack, NULL));
|
|
|
|
_grossini->runAction(CCSequence::create(actionBy, actionByBack, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(CCSequence::create(actionBy2, actionBy2->reverse(), NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string ActionSkew::subtitle()
|
|
|
|
{
|
|
|
|
return "SkewTo / SkewBy";
|
|
|
|
}
|
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
// ActionRotationalSkew
|
|
|
|
void ActionRotationalSkew::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
this->centerSprites(3);
|
|
|
|
|
|
|
|
CCRotateTo* actionTo = CCRotateTo::create(2, 37.2f, -37.2f);
|
|
|
|
CCRotateTo* actionToBack = CCRotateTo::create(2, 0, 0);
|
|
|
|
CCRotateBy* actionBy = CCRotateBy::create(2, 0.0f, -90.0f);
|
|
|
|
CCRotateBy* actionBy2 = CCRotateBy::create(2, 45.0f, 45.0f);
|
|
|
|
CCRotateBy* actionByBack = (CCRotateBy*)actionBy->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(CCSequence::create(actionTo, actionToBack, NULL));
|
|
|
|
_grossini->runAction(CCSequence::create(actionBy, actionByBack, NULL));
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(CCSequence::create(actionBy2, actionBy2->reverse(), NULL));
|
2013-02-28 14:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRotationalSkew::subtitle()
|
|
|
|
{
|
|
|
|
return "RotationalSkewTo / RotationalSkewBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ActionRotationalSkewVSStandardSkew
|
|
|
|
void ActionRotationalSkewVSStandardSkew::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->removeFromParentAndCleanup(true);
|
|
|
|
_grossini->removeFromParentAndCleanup(true);
|
|
|
|
_kathia->removeFromParentAndCleanup(true);
|
2013-02-28 14:42:45 +08:00
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
CCSize boxSize = CCSizeMake(100.0f, 100.0f);
|
|
|
|
|
|
|
|
CCLayerColor *box = CCLayerColor::create(ccc4(255,255,0,255));
|
|
|
|
box->setAnchorPoint(ccp(0.5,0.5));
|
|
|
|
box->setContentSize( boxSize );
|
|
|
|
box->ignoreAnchorPointForPosition(false);
|
|
|
|
box->setPosition(ccp(s.width/2, s.height - 100 - box->getContentSize().height/2));
|
|
|
|
this->addChild(box);
|
|
|
|
CCLabelTTF *label = CCLabelTTF::create("Standard cocos2d Skew", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp(s.width/2, s.height - 100 + label->getContentSize().height));
|
|
|
|
this->addChild(label);
|
|
|
|
CCSkewBy* actionTo = CCSkewBy::create(2, 360, 0);
|
|
|
|
CCSkewBy* actionToBack = CCSkewBy::create(2, -360, 0);
|
|
|
|
|
|
|
|
box->runAction(CCSequence::create(actionTo, actionToBack, NULL));
|
|
|
|
|
|
|
|
box = CCLayerColor::create(ccc4(255,255,0,255));
|
|
|
|
box->setAnchorPoint(ccp(0.5,0.5));
|
|
|
|
box->setContentSize(boxSize);
|
|
|
|
box->ignoreAnchorPointForPosition(false);
|
|
|
|
box->setPosition(ccp(s.width/2, s.height - 250 - box->getContentSize().height/2));
|
|
|
|
this->addChild(box);
|
|
|
|
label = CCLabelTTF::create("Rotational Skew", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp(s.width/2, s.height - 250 + label->getContentSize().height/2));
|
|
|
|
this->addChild(label);
|
|
|
|
CCRotateBy* actionTo2 = CCRotateBy::create(2, 360, 0);
|
|
|
|
CCRotateBy* actionToBack2 = CCRotateBy::create(2, -360, 0);
|
|
|
|
box->runAction(CCSequence::create(actionTo2, actionToBack2, NULL));
|
|
|
|
}
|
|
|
|
std::string ActionRotationalSkewVSStandardSkew::subtitle()
|
|
|
|
{
|
|
|
|
return "Skew Comparison";
|
|
|
|
}
|
2012-11-19 17:15:16 +08:00
|
|
|
|
|
|
|
// ActionSkewRotateScale
|
2012-04-19 14:35:52 +08:00
|
|
|
void ActionSkewRotateScale::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->removeFromParentAndCleanup(true);
|
|
|
|
_grossini->removeFromParentAndCleanup(true);
|
|
|
|
_kathia->removeFromParentAndCleanup(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCSize boxSize = CCSizeMake(100.0f, 100.0f);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor *box = CCLayerColor::create(ccc4(255, 255, 0, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
box->setAnchorPoint(ccp(0, 0));
|
|
|
|
box->setPosition(ccp(190, 110));
|
|
|
|
box->setContentSize(boxSize);
|
|
|
|
|
|
|
|
static float markrside = 10.0f;
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor *uL = CCLayerColor::create(ccc4(255, 0, 0, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
box->addChild(uL);
|
|
|
|
uL->setContentSize(CCSizeMake(markrside, markrside));
|
|
|
|
uL->setPosition(ccp(0.f, boxSize.height - markrside));
|
|
|
|
uL->setAnchorPoint(ccp(0, 0));
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor *uR = CCLayerColor::create(ccc4(0, 0, 255, 255));
|
2012-04-19 14:35:52 +08:00
|
|
|
box->addChild(uR);
|
|
|
|
uR->setContentSize(CCSizeMake(markrside, markrside));
|
|
|
|
uR->setPosition(ccp(boxSize.width - markrside, boxSize.height - markrside));
|
|
|
|
uR->setAnchorPoint(ccp(0, 0));
|
|
|
|
addChild(box);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *actionTo = CCSkewTo::create(2, 0.f, 2.f);
|
|
|
|
CCActionInterval *rotateTo = CCRotateTo::create(2, 61.0f);
|
|
|
|
CCActionInterval *actionScaleTo = CCScaleTo::create(2, -0.44f, 0.47f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *actionScaleToBack = CCScaleTo::create(2, 1.0f, 1.0f);
|
|
|
|
CCActionInterval *rotateToBack = CCRotateTo::create(2, 0);
|
|
|
|
CCActionInterval *actionToBack = CCSkewTo::create(2, 0, 0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
box->runAction(CCSequence::create(actionTo, actionToBack, NULL));
|
|
|
|
box->runAction(CCSequence::create(rotateTo, rotateToBack, NULL));
|
|
|
|
box->runAction(CCSequence::create(actionScaleTo, actionScaleToBack, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string ActionSkewRotateScale::subtitle()
|
|
|
|
{
|
|
|
|
return "Skew + Rotate + Scale";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRotate
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRotate::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* actionTo = CCRotateTo::create( 2, 45);
|
|
|
|
CCActionInterval* actionTo2 = CCRotateTo::create( 2, -45);
|
|
|
|
CCActionInterval* actionTo0 = CCRotateTo::create(2 , 0);
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( CCSequence::create(actionTo, actionTo0, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* actionBy = CCRotateBy::create(2 , 360);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* actionByBack = actionBy->reverse();
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-19 06:06:53 +08:00
|
|
|
_kathia->runAction( CCSequence::create(actionTo2, actionTo0->clone(), NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRotate::subtitle()
|
|
|
|
{
|
|
|
|
return "RotateTo / RotateBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionJump
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionJump::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* actionTo = CCJumpTo::create(2, ccp(300,300), 50, 4);
|
|
|
|
CCActionInterval* actionBy = CCJumpBy::create(2, ccp(300,0), 50, 4);
|
|
|
|
CCActionInterval* actionUp = CCJumpBy::create(2, ccp(0,0), 80, 4);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* actionByBack = actionBy->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( actionTo);
|
|
|
|
_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL));
|
|
|
|
_kathia->runAction( CCRepeatForever::create(actionUp));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
std::string ActionJump::subtitle()
|
|
|
|
{
|
|
|
|
return "JumpTo / JumpBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionBezier
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionBezier::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
//
|
|
|
|
// startPosition can be any coordinate, but since the movement
|
|
|
|
// is relative to the Bezier curve, make it (0,0)
|
|
|
|
//
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
|
|
|
// sprite 1
|
|
|
|
ccBezierConfig bezier;
|
2012-10-23 17:48:50 +08:00
|
|
|
bezier.controlPoint_1 = ccp(0, s.height/2);
|
|
|
|
bezier.controlPoint_2 = ccp(300, -s.height/2);
|
|
|
|
bezier.endPosition = ccp(300,100);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* bezierForward = CCBezierBy::create(3, bezier);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* bezierBack = bezierForward->reverse();
|
2013-06-19 06:06:53 +08:00
|
|
|
CCAction* rep = CCRepeatForever::create((CCActionInterval*)CCSequence::create( bezierForward, bezierBack, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// sprite 2
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setPosition(ccp(80,160));
|
2012-04-19 14:35:52 +08:00
|
|
|
ccBezierConfig bezier2;
|
2012-10-23 17:48:50 +08:00
|
|
|
bezier2.controlPoint_1 = ccp(100, s.height/2);
|
|
|
|
bezier2.controlPoint_2 = ccp(200, -s.height/2);
|
|
|
|
bezier2.endPosition = ccp(240,160);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* bezierTo1 = CCBezierTo::create(2, bezier2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// sprite 3
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition(ccp(400,160));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* bezierTo2 = CCBezierTo::create(2, bezier2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction( rep);
|
|
|
|
_tamara->runAction(bezierTo1);
|
|
|
|
_kathia->runAction(bezierTo2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionBezier::subtitle()
|
|
|
|
{
|
|
|
|
return "BezierBy / BezierTo";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionBlink
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionBlink::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(2);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* action1 = CCBlink::create(2, 10);
|
|
|
|
CCActionInterval* action2 = CCBlink::create(2, 5);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( action1);
|
|
|
|
_kathia->runAction(action2);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionBlink::subtitle()
|
|
|
|
{
|
|
|
|
return "Blink";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionFade
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionFade::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(2);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setOpacity( 0 );
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* action1 = CCFadeIn::create(1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* action1Back = action1->reverse();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* action2 = CCFadeOut::create(1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* action2Back = action2->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( CCSequence::create( action1, action1Back, NULL));
|
|
|
|
_kathia->runAction( CCSequence::create( action2, action2Back, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionFade::subtitle()
|
|
|
|
{
|
|
|
|
return "FadeIn / FadeOut";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionTint
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ActionTint::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(2);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* action1 = CCTintTo::create(2, 255, 0, 255);
|
|
|
|
CCActionInterval* action2 = CCTintBy::create(2, -127, -255, -127);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* action2Back = action2->reverse();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( action1);
|
|
|
|
_kathia->runAction( CCSequence::create( action2, action2Back, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionTint::subtitle()
|
|
|
|
{
|
|
|
|
return "TintTo / TintBy";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionAnimate
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionAnimate::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-07-23 22:49:11 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
// Manual animation
|
|
|
|
//
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAnimation* animation = CCAnimation::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
for( int i=1;i<15;i++)
|
|
|
|
{
|
|
|
|
char szName[100] = {0};
|
|
|
|
sprintf(szName, "Images/grossini_dance_%02d.png", i);
|
|
|
|
animation->addSpriteFrameWithFileName(szName);
|
|
|
|
}
|
|
|
|
// should last 2.8 seconds. And there are 14 frames.
|
|
|
|
animation->setDelayPerUnit(2.8f / 14.0f);
|
|
|
|
animation->setRestoreOriginalFrame(true);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAnimate* action = CCAnimate::create(animation);
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(CCSequence::create(action, action->reverse(), NULL));
|
2012-07-23 22:49:11 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
// File animation
|
|
|
|
//
|
|
|
|
// With 2 loops and reverse
|
|
|
|
CCAnimationCache *cache = CCAnimationCache::sharedAnimationCache();
|
|
|
|
cache->addAnimationsWithFile("animations/animations-2.plist");
|
|
|
|
CCAnimation *animation2 = cache->animationByName("dance_1");
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAnimate* action2 = CCAnimate::create(animation2);
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(CCSequence::create(action2, action2->reverse(), NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:CCAnimationFrameDisplayedNotification object:nil queue:nil usingBlock:^(NSNotification* notification) {
|
|
|
|
//
|
2013-02-28 14:42:45 +08:00
|
|
|
// NSDictionary *userInfo = [notification userInfo);
|
2013-02-28 15:32:27 +08:00
|
|
|
// NSLog(@"object %@ with data %@", [notification object), userInfo );
|
2013-02-28 14:42:45 +08:00
|
|
|
// });
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// File animation
|
|
|
|
//
|
|
|
|
// with 4 loops
|
2013-06-19 06:06:53 +08:00
|
|
|
CCAnimation *animation3 = animation2->clone();
|
2012-04-19 14:35:52 +08:00
|
|
|
animation3->setLoops(4);
|
|
|
|
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAnimate* action3 = CCAnimate::create(animation3);
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(action3);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionAnimate::onExit()
|
|
|
|
{
|
|
|
|
ActionsDemo::onExit();
|
2013-02-28 14:42:45 +08:00
|
|
|
//TODO:[[NSNotificationCenter defaultCenter] removeObserver:observer_);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionAnimate::title()
|
|
|
|
{
|
|
|
|
return "Animation";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionAnimate::subtitle()
|
|
|
|
{
|
|
|
|
return "Center: Manual animation. Border: using file format animation";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionSequence
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionSequence::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create(
|
2012-10-23 17:48:50 +08:00
|
|
|
CCMoveBy::create( 2, ccp(240,0)),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy::create( 2, 540),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionSequence::subtitle()
|
|
|
|
{
|
|
|
|
return "Sequence: Move + Rotate";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionSequence2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionSequence2::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setVisible(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create(
|
2013-06-04 03:13:24 +08:00
|
|
|
CCPlace::create(ccp(200,200)),
|
|
|
|
CCShow::create(),
|
|
|
|
CCMoveBy::create(1, ccp(100,0)),
|
2013-06-14 11:36:43 +08:00
|
|
|
// CC_CALLBACK_0 == std::bind( &function, instance, ...)
|
|
|
|
CCCallFunc::create( CC_CALLBACK_0(ActionSequence2::callback1,this)),
|
2013-06-15 14:03:30 +08:00
|
|
|
CCCallFunc::create( CC_CALLBACK_0(ActionSequence2::callback2,this,_grossini)),
|
|
|
|
CCCallFunc::create( CC_CALLBACK_0(ActionSequence2::callback3,this,_grossini,(void*)0xbebabeba)),
|
2013-06-04 03:13:24 +08:00
|
|
|
NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionSequence2::callback1()
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*1,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionSequence2::callback2(CCNode* sender)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*2,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionSequence2::callback3(CCNode* sender, void* data)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*3,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionSequence2::subtitle()
|
|
|
|
{
|
|
|
|
return "Sequence of InstantActions";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionCallFunc
|
2013-06-04 03:13:24 +08:00
|
|
|
// DEPRECATED. Use the std::function() API instead
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionCallFunc::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create(
|
2012-10-23 17:48:50 +08:00
|
|
|
CCMoveBy::create(2, ccp(200,0)),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(ActionCallFunc::callback1)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action2 = CCSequence::create(
|
|
|
|
CCScaleBy::create(2 , 2),
|
|
|
|
CCFadeOut::create(2),
|
|
|
|
CCCallFuncN::create(this, callfuncN_selector(ActionSequence2::callback2)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action3 = CCSequence::create(
|
|
|
|
CCRotateBy::create(3 , 360),
|
|
|
|
CCFadeOut::create(2),
|
|
|
|
CCCallFuncND::create(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
|
|
|
_tamara->runAction(action2);
|
|
|
|
_kathia->runAction(action3);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionCallFunc::callback1()
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*1,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCallFunc::callback2(CCNode* pSender)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*2,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCallFunc::callback3(CCNode* pTarget, void* data)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16);
|
2012-10-23 17:48:50 +08:00
|
|
|
label->setPosition(ccp( s.width/4*3,s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCallFunc::subtitle()
|
|
|
|
{
|
2013-06-04 03:13:24 +08:00
|
|
|
return "Callbacks: CallFunc. Old way. Avoid it";
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionCallFuncND
|
2013-06-04 03:13:24 +08:00
|
|
|
// DEPRECATED. Use the std::function() API instead
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionCallFuncND::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(1);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)),
|
|
|
|
CCCallFuncND::create(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCallFuncND::title()
|
|
|
|
{
|
|
|
|
return "CallFuncND + auto remove";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCallFuncND::subtitle()
|
|
|
|
{
|
|
|
|
return "CallFuncND + removeFromParentAndCleanup. Grossini dissapears in 2s";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCallFuncND::removeFromParentAndCleanup(CCNode* pSender, void* data)
|
|
|
|
{
|
2012-08-25 02:20:23 +08:00
|
|
|
bool bCleanUp = data != NULL;
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->removeFromParentAndCleanup(bCleanUp);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-04 03:13:24 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionCallFunction
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionCallFunction::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
|
|
|
|
|
|
|
CCFiniteTimeAction* action1 = CCSequence::create(
|
|
|
|
CCMoveBy::create(2, ccp(200,0)),
|
|
|
|
CCCallFunc::create( std::bind(&ActionCallFunction::callback1, this) ),
|
|
|
|
CCCallFunc::create(
|
|
|
|
// lambda
|
|
|
|
[&](){
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
CCLabelTTF *label = CCLabelTTF::create("called:lambda callback", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp( s.width/4*1,s.height/2-40));
|
|
|
|
this->addChild(label);
|
|
|
|
} ),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
CCFiniteTimeAction* action2 = CCSequence::create(
|
|
|
|
CCScaleBy::create(2 , 2),
|
|
|
|
CCFadeOut::create(2),
|
2013-06-15 14:03:30 +08:00
|
|
|
CCCallFunc::create( std::bind(&ActionCallFunction::callback2, this, _tamara) ),
|
2013-06-04 03:13:24 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
CCFiniteTimeAction* action3 = CCSequence::create(
|
|
|
|
CCRotateBy::create(3 , 360),
|
|
|
|
CCFadeOut::create(2),
|
2013-06-15 14:03:30 +08:00
|
|
|
CCCallFunc::create( std::bind(&ActionCallFunction::callback3, this, _kathia, (void*)42) ),
|
2013-06-04 03:13:24 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action1);
|
|
|
|
_tamara->runAction(action2);
|
|
|
|
_kathia->runAction(action3);
|
2013-06-04 03:13:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionCallFunction::callback1()
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp( s.width/4*1,s.height/2));
|
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCallFunction::callback2(CCNode* sender)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp( s.width/4*2,s.height/2));
|
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
|
|
|
|
CCLOG("sender is: %p", sender);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCallFunction::callback3(CCNode* sender, void* data)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16);
|
|
|
|
label->setPosition(ccp( s.width/4*3,s.height/2));
|
|
|
|
addChild(label);
|
|
|
|
|
|
|
|
CCLOG("target is: %p, data is: %ld", sender, (long)data);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCallFunction::subtitle()
|
|
|
|
{
|
|
|
|
return "Callbacks: CallFunc with std::function()";
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionSpawn
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ActionSpawn::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction* action = CCSpawn::create(
|
2012-10-23 17:48:50 +08:00
|
|
|
CCJumpBy::create(2, ccp(300,0), 50, 4),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy::create( 2, 720),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionSpawn::subtitle()
|
|
|
|
{
|
|
|
|
return "Spawn: Jump + Rotate";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRepeatForever
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRepeatForever::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(1);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create(
|
|
|
|
CCDelayTime::create(1),
|
2013-06-15 14:03:30 +08:00
|
|
|
CCCallFunc::create( std::bind( &ActionRepeatForever::repeatForever, this, _grossini) ),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionRepeatForever::repeatForever(CCNode* pSender)
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRepeatForever *repeat = CCRepeatForever::create( CCRotateBy::create(1.0f, 360) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
pSender->runAction(repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRepeatForever::subtitle()
|
|
|
|
{
|
|
|
|
return "CallFuncN + RepeatForever";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRotateToRepeat
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRotateToRepeat::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(2);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* act1 = CCRotateTo::create(1, 90);
|
|
|
|
CCActionInterval* act2 = CCRotateTo::create(1, 0);
|
2012-12-10 14:12:56 +08:00
|
|
|
CCActionInterval* seq = CCSequence::create(act1, act2, NULL);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction* rep1 = CCRepeatForever::create(seq);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCActionInterval* rep2 = CCRepeat::create( seq->clone(), 10);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(rep1);
|
|
|
|
_kathia->runAction(rep2);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRotateToRepeat ::subtitle()
|
|
|
|
{
|
|
|
|
return "Repeat/RepeatForever + RotateTo";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRotateJerk
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRotateJerk::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(2);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* seq = CCSequence::create(
|
|
|
|
CCRotateTo::create(0.5f, -20),
|
|
|
|
CCRotateTo::create(0.5f, 20),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* rep1 = CCRepeat::create(seq, 10);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCAction* rep2 = CCRepeatForever::create( (CCActionInterval*) seq->clone() );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(rep1);
|
|
|
|
_kathia->runAction(rep2);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRotateJerk::subtitle()
|
|
|
|
{
|
|
|
|
return "RepeatForever / Repeat + Rotate";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionReverse
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionReverse::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* jump = CCJumpBy::create(2, ccp(300,0), 50, 4);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create( jump, jump->reverse(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionReverse::subtitle()
|
|
|
|
{
|
|
|
|
return "Reverse an action";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionDelayTime
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionDelayTime::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* move = CCMoveBy::create(1, ccp(150,0));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* action = CCSequence::create( move, CCDelayTime::create(2), move, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionDelayTime::subtitle()
|
|
|
|
{
|
|
|
|
return "DelayTime: m + delay + m";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionReverseSequence
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionReverseSequence::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* move1 = CCMoveBy::create(1, ccp(250,0));
|
|
|
|
CCActionInterval* move2 = CCMoveBy::create(1, ccp(0,50));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* seq = CCSequence::create( move1, move2, move1->reverse(), NULL);
|
|
|
|
CCFiniteTimeAction* action = CCSequence::create( seq, seq->reverse(), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionReverseSequence::subtitle()
|
|
|
|
{
|
|
|
|
return "Reverse a sequence";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionReverseSequence2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionReverseSequence2::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(2);
|
|
|
|
|
|
|
|
|
|
|
|
// Test:
|
|
|
|
// Sequence should work both with IntervalAction and InstantActions
|
2013-06-19 06:06:53 +08:00
|
|
|
auto move1 = CCMoveBy::create(1, ccp(250,0));
|
|
|
|
auto move2 = CCMoveBy::create(1, ccp(0,50));
|
|
|
|
auto tog1 = CCToggleVisibility::create();
|
|
|
|
auto tog2 = CCToggleVisibility::create();
|
|
|
|
auto seq = CCSequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL);
|
|
|
|
auto action = CCRepeat::create(CCSequence::create( seq, seq->reverse(), NULL), 3);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Test:
|
|
|
|
// Also test that the reverse of Hide is Show, and vice-versa
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-19 06:06:53 +08:00
|
|
|
auto move_tamara = CCMoveBy::create(1, ccp(100,0));
|
|
|
|
auto move_tamara2 = CCMoveBy::create(1, ccp(50,0));
|
|
|
|
auto hide = CCHide::create();
|
|
|
|
auto seq_tamara = CCSequence::create( move_tamara, hide, move_tamara2, NULL);
|
|
|
|
auto seq_back = seq_tamara->reverse();
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction( CCSequence::create( seq_tamara, seq_back, NULL));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
std::string ActionReverseSequence2::subtitle()
|
|
|
|
{
|
|
|
|
return "Reverse sequence 2";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRepeat
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRepeat::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(2);
|
|
|
|
|
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* a1 = CCMoveBy::create(1, ccp(150,0));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* action1 = CCRepeat::create(
|
2012-10-23 17:48:50 +08:00
|
|
|
CCSequence::create( CCPlace::create(ccp(60,60)), a1, NULL) ,
|
2012-04-19 14:35:52 +08:00
|
|
|
3);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction* action2 = CCRepeatForever::create(
|
2013-06-19 06:06:53 +08:00
|
|
|
CCSequence::create((CCActionInterval*)(a1->clone()), a1->reverse(), NULL)
|
2012-04-19 14:35:52 +08:00
|
|
|
);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(action1);
|
|
|
|
_tamara->runAction(action2);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRepeat::subtitle()
|
|
|
|
{
|
|
|
|
return "Repeat / RepeatForever actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionOrbit
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionOrbit::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(3);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* orbit1 = CCOrbitCamera::create(2,1, 0, 0, 180, 0, 0);
|
2012-12-10 14:12:56 +08:00
|
|
|
CCSequence* action1 = CCSequence::create(
|
2012-04-19 14:35:52 +08:00
|
|
|
orbit1,
|
|
|
|
orbit1->reverse(),
|
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* orbit2 = CCOrbitCamera::create(2,1, 0, 0, 180, -45, 0);
|
2012-12-10 14:12:56 +08:00
|
|
|
CCSequence* action2 = CCSequence::create(
|
2012-04-19 14:35:52 +08:00
|
|
|
orbit2,
|
|
|
|
orbit2->reverse(),
|
|
|
|
NULL);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* orbit3 = CCOrbitCamera::create(2,1, 0, 0, 180, 90, 0);
|
2012-12-10 14:12:56 +08:00
|
|
|
CCSequence* action3 = CCSequence::create(
|
2012-04-19 14:35:52 +08:00
|
|
|
orbit3,
|
|
|
|
orbit3->reverse(),
|
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(CCRepeatForever::create(action1));
|
|
|
|
_tamara->runAction(CCRepeatForever::create(action2));
|
|
|
|
_grossini->runAction(CCRepeatForever::create(action3));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* move = CCMoveBy::create(3, ccp(100,-100));
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* move_back = move->reverse();
|
2012-12-10 14:12:56 +08:00
|
|
|
CCSequence* seq = CCSequence::create(move, move_back, NULL);
|
|
|
|
CCAction* rfe = CCRepeatForever::create(seq);
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(rfe);
|
2013-06-19 06:06:53 +08:00
|
|
|
_tamara->runAction(rfe->clone() );
|
|
|
|
_grossini->runAction( rfe->clone() );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionOrbit::subtitle()
|
|
|
|
{
|
|
|
|
return "OrbitCamera action";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionFollow
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionFollow::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
centerSprites(1);
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->setPosition(ccp(-200, s.height / 2));
|
2012-10-23 17:48:50 +08:00
|
|
|
CCActionInterval* move = CCMoveBy::create(2, ccp(s.width * 3, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* move_back = move->reverse();
|
2012-12-10 14:12:56 +08:00
|
|
|
CCSequence* seq = CCSequence::create(move, move_back, NULL);
|
|
|
|
CCAction* rep = CCRepeatForever::create(seq);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(rep);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
this->runAction(CCFollow::create(_grossini, CCRectMake(0, 0, s.width * 2 - 100, s.height)));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-03-01 11:12:23 +08:00
|
|
|
void ActionFollow::draw()
|
|
|
|
{
|
|
|
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
float x = winSize.width*2 - 100;
|
|
|
|
float y = winSize.height;
|
|
|
|
|
|
|
|
CCPoint vertices[] = { ccp(5,5), ccp(x-5,5), ccp(x-5,y-5), ccp(5,y-5) };
|
|
|
|
ccDrawPoly(vertices, 4, true);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
std::string ActionFollow::subtitle()
|
|
|
|
{
|
|
|
|
return "Follow action";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionTargeted::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(2);
|
|
|
|
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCJumpBy* jump1 = CCJumpBy::create(2,CCPointZero,100,3);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCJumpBy* jump2 = jump1->clone();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy* rot1 = CCRotateBy::create(1, 360);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCRotateBy* rot2 = rot1->clone();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CCTargetedAction *t1 = CCTargetedAction::create(_kathia, jump2);
|
|
|
|
CCTargetedAction *t2 = CCTargetedAction::create(_kathia, rot2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence* seq = (CCSequence*)CCSequence::create(jump1, t1, rot1, t2, NULL);
|
|
|
|
CCRepeatForever *always = CCRepeatForever::create(seq);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(always);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionTargeted::title()
|
|
|
|
{
|
|
|
|
return "ActionTargeted";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionTargeted::subtitle()
|
|
|
|
{
|
|
|
|
return "Action that runs on another target. Useful for sequences";
|
|
|
|
}
|
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
//#pragma mark - ActionStacked
|
|
|
|
|
|
|
|
void ActionStacked::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
this->centerSprites(0);
|
|
|
|
|
|
|
|
this->setTouchEnabled(true);
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
this->addNewSpriteWithCoords(ccp(s.width/2, s.height/2));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionStacked::addNewSpriteWithCoords(CCPoint p)
|
|
|
|
{
|
2013-02-28 15:32:27 +08:00
|
|
|
int idx = CCRANDOM_0_1() * 1400 / 100;
|
|
|
|
int x = (idx%5) * 85;
|
|
|
|
int y = (idx/5) * 121;
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCSprite *sprite = CCSprite::create("Images/grossini_dance_atlas.png", CCRectMake(x,y,85,121));
|
|
|
|
|
|
|
|
sprite->setPosition(p);
|
|
|
|
this->addChild(sprite);
|
|
|
|
|
|
|
|
this->runActionsInSprite(sprite);
|
2013-02-28 14:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionStacked::runActionsInSprite(CCSprite *sprite)
|
|
|
|
{
|
2013-02-28 15:32:27 +08:00
|
|
|
// override me
|
2013-02-28 14:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionStacked::ccTouchesEnded(CCSet* touches, CCEvent* event)
|
|
|
|
{
|
|
|
|
CCSetIterator it;
|
|
|
|
CCTouch* touch;
|
|
|
|
|
|
|
|
for( it = touches->begin(); it != touches->end(); it++)
|
|
|
|
{
|
|
|
|
touch = (CCTouch*)(*it);
|
|
|
|
|
|
|
|
if(!touch)
|
|
|
|
break;
|
|
|
|
|
|
|
|
CCPoint location = touch->getLocation();
|
|
|
|
|
|
|
|
addNewSpriteWithCoords( location );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionStacked::title()
|
|
|
|
{
|
|
|
|
return "Override me";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionStacked::subtitle()
|
|
|
|
{
|
|
|
|
return "Tap screen";
|
|
|
|
}
|
|
|
|
|
|
|
|
//#pragma mark - ActionMoveStacked
|
|
|
|
|
|
|
|
|
|
|
|
void ActionMoveStacked::runActionsInSprite(CCSprite *sprite)
|
|
|
|
{
|
2013-02-28 15:32:27 +08:00
|
|
|
sprite->runAction(
|
2013-02-28 14:42:45 +08:00
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,10)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,-10)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy* action = CCMoveBy::create(2.0f, ccp(400,0));
|
2013-06-19 06:06:53 +08:00
|
|
|
CCMoveBy* action_back = action->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
sprite->runAction(
|
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(action, action_back, NULL)
|
|
|
|
));
|
2013-02-28 14:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string ActionMoveStacked::title()
|
|
|
|
{
|
2013-02-28 15:32:27 +08:00
|
|
|
return "Stacked CCMoveBy/To actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
//#pragma mark - ActionMoveJumpStacked
|
|
|
|
|
|
|
|
void ActionMoveJumpStacked::runActionsInSprite(CCSprite *sprite)
|
|
|
|
{
|
|
|
|
sprite->runAction(
|
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,2)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,-2)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
2013-06-10 11:44:16 +08:00
|
|
|
CCJumpBy* jump = CCJumpBy::create(2.0f, ccp(400,0), 100, 5);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCJumpBy* jump_back = jump->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
sprite->runAction(
|
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(jump, jump_back, NULL)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionMoveJumpStacked::title()
|
|
|
|
{
|
|
|
|
return "tacked Move + Jump actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
//#pragma mark - ActionMoveBezierStacked
|
|
|
|
|
|
|
|
void ActionMoveBezierStacked::runActionsInSprite(CCSprite *sprite)
|
|
|
|
{
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
// sprite 1
|
|
|
|
ccBezierConfig bezier;
|
|
|
|
bezier.controlPoint_1 = ccp(0, s.height/2);
|
|
|
|
bezier.controlPoint_2 = ccp(300, -s.height/2);
|
|
|
|
bezier.endPosition = ccp(300,100);
|
|
|
|
|
|
|
|
CCBezierBy* bezierForward = CCBezierBy::create(3, bezier);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCBezierBy* bezierBack = bezierForward->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
CCSequence* seq = CCSequence::create(bezierForward, bezierBack, NULL);
|
|
|
|
CCRepeatForever* rep = CCRepeatForever::create(seq);
|
|
|
|
sprite->runAction(rep);
|
|
|
|
|
|
|
|
sprite->runAction(
|
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,0)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,0)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionMoveBezierStacked::title()
|
|
|
|
{
|
|
|
|
return "Stacked Move + Bezier actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#pragma mark - ActionCatmullRomStacked
|
|
|
|
|
|
|
|
void ActionCatmullRomStacked::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
this->centerSprites(2);
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 1 (By)
|
|
|
|
//
|
|
|
|
// startPosition can be any coordinate, but since the movement
|
|
|
|
// is relative to the Catmull Rom curve, it is better to start with (0,0).
|
|
|
|
//
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setPosition(ccp(50,50));
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCPointArray *array = CCPointArray::create(20);
|
|
|
|
|
|
|
|
array->addControlPoint(ccp(0,0));
|
|
|
|
array->addControlPoint(ccp(80,80));
|
|
|
|
array->addControlPoint(ccp(s.width-80,80));
|
|
|
|
array->addControlPoint(ccp(s.width-80,s.height-80));
|
|
|
|
array->addControlPoint(ccp(80,s.height-80));
|
|
|
|
array->addControlPoint(ccp(80,80));
|
|
|
|
array->addControlPoint(ccp(s.width/2, s.height/2));
|
|
|
|
|
|
|
|
CCCatmullRomBy *action = CCCatmullRomBy::create(3, array);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCCatmullRomBy* reverse = action->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCSequence *seq = CCSequence::create(action, reverse, NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(seq);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(
|
2013-02-28 15:32:27 +08:00
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,0)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,0)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 2 (To)
|
|
|
|
//
|
|
|
|
// The startPosition is not important here, because it uses a "To" action.
|
|
|
|
// The initial position will be the 1st point of the Catmull Rom path
|
|
|
|
//
|
|
|
|
|
|
|
|
CCPointArray *array2 = CCPointArray::create(20);
|
|
|
|
|
|
|
|
array2->addControlPoint(ccp(s.width/2, 30));
|
|
|
|
array2->addControlPoint(ccp(s.width-80,30));
|
|
|
|
array2->addControlPoint(ccp(s.width-80,s.height-80));
|
|
|
|
array2->addControlPoint(ccp(s.width/2,s.height-80));
|
|
|
|
array2->addControlPoint(ccp(s.width/2, 30));
|
|
|
|
|
|
|
|
|
|
|
|
CCCatmullRomTo *action2 = CCCatmullRomTo::create(3, array2);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCCatmullRomTo* reverse2 = action2->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCSequence *seq2 = CCSequence::create(action2, reverse2, NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(seq2);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(
|
2013-02-28 15:32:27 +08:00
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,0)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,0)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
|
|
|
|
|
|
|
array->retain();
|
|
|
|
_array1 = array;
|
|
|
|
array2->retain();
|
|
|
|
_array2 = array2;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionCatmullRomStacked::~ActionCatmullRomStacked()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_array1);
|
|
|
|
CC_SAFE_RELEASE(_array2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCatmullRomStacked::draw()
|
|
|
|
{
|
|
|
|
ActionsDemo::draw();
|
|
|
|
|
|
|
|
// move to 50,50 since the "by" path will start at 50,50
|
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(50, 50, 0);
|
|
|
|
ccDrawCatmullRom(_array1,50);
|
|
|
|
kmGLPopMatrix();
|
|
|
|
|
|
|
|
ccDrawCatmullRom(_array2,50);
|
|
|
|
}
|
2013-02-28 14:42:45 +08:00
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
std::string ActionCatmullRomStacked::title()
|
|
|
|
{
|
|
|
|
return "Stacked MoveBy + CatmullRom actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCatmullRomStacked::subtitle()
|
|
|
|
{
|
|
|
|
return "MoveBy + CatmullRom at the same time in the same sprite";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#pragma mark - ActionCardinalSplineStacked
|
|
|
|
|
|
|
|
void ActionCardinalSplineStacked::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
this->centerSprites(2);
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
CCPointArray *array = CCPointArray::create(20);
|
|
|
|
|
|
|
|
array->addControlPoint(ccp(0, 0));
|
|
|
|
array->addControlPoint(ccp(s.width/2-30,0));
|
|
|
|
array->addControlPoint(ccp(s.width/2-30,s.height-80));
|
|
|
|
array->addControlPoint(ccp(0, s.height-80));
|
|
|
|
array->addControlPoint(ccp(0, 0));
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 1 (By)
|
|
|
|
//
|
|
|
|
// Spline with no tension (tension==0)
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
CCCatmullRomBy *action = (CCCatmullRomBy*)CCCardinalSplineBy::create(3, array, 0);
|
2013-06-19 06:06:53 +08:00
|
|
|
CCCatmullRomBy* reverse = action->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCSequence *seq = CCSequence::create(action, reverse, NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setPosition(ccp(50,50));
|
|
|
|
_tamara->runAction(seq);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(
|
2013-02-28 15:32:27 +08:00
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,0)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,0)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 2 (By)
|
|
|
|
//
|
|
|
|
// Spline with high tension (tension==1)
|
|
|
|
//
|
|
|
|
|
2013-06-19 06:06:53 +08:00
|
|
|
CCCardinalSplineBy *action2 = CCCardinalSplineBy::create(3, array, 1);
|
|
|
|
CCCardinalSplineBy* reverse2 = action2->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
CCSequence *seq2 = CCSequence::create(action2, reverse2, NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition(ccp(s.width/2,50));
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(seq2);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(
|
2013-02-28 15:32:27 +08:00
|
|
|
CCRepeatForever::create(
|
|
|
|
CCSequence::create(
|
2013-06-10 11:44:16 +08:00
|
|
|
CCMoveBy::create(0.05f, ccp(10,0)),
|
|
|
|
CCMoveBy::create(0.05f, ccp(-10,0)),
|
2013-02-28 15:32:27 +08:00
|
|
|
NULL)));
|
|
|
|
|
|
|
|
|
|
|
|
array->retain();
|
|
|
|
_array = array;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionCardinalSplineStacked::~ActionCardinalSplineStacked()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCardinalSplineStacked::draw()
|
|
|
|
{
|
|
|
|
ActionsDemo::draw();
|
|
|
|
|
|
|
|
// move to 50,50 since the "by" path will start at 50,50
|
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(50, 50, 0);
|
|
|
|
ccDrawCardinalSpline(_array, 0, 100);
|
|
|
|
kmGLPopMatrix();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(s.width/2, 50, 0);
|
|
|
|
ccDrawCardinalSpline(_array, 1, 100);
|
|
|
|
kmGLPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCardinalSplineStacked::title()
|
|
|
|
{
|
|
|
|
return "Stacked MoveBy + CardinalSpline actions";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionCardinalSplineStacked::subtitle()
|
|
|
|
{
|
|
|
|
return "CCMoveBy + CCCardinalSplineBy/To at the same time";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Issue1305
|
2012-04-19 14:35:52 +08:00
|
|
|
void Issue1305::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(0);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_spriteTmp = CCSprite::create("Images/grossini.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
/* c++ can't support block, so we use CCCallFuncN instead.
|
|
|
|
[spriteTmp_ runAction:[CCCallBlockN actionWithBlock:^(CCNode* node) {
|
|
|
|
NSLog(@"This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
2013-02-28 14:42:45 +08:00
|
|
|
}] );
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_spriteTmp->runAction(CCCallFunc::create(std::bind(&Issue1305::log, this, _spriteTmp)));
|
|
|
|
_spriteTmp->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
scheduleOnce(schedule_selector(Issue1305::addSprite), 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1305::log(CCNode* pSender)
|
|
|
|
{
|
|
|
|
CCLog("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1305::onExit()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_spriteTmp->stopAllActions();
|
|
|
|
_spriteTmp->release();
|
2012-05-30 16:09:19 +08:00
|
|
|
ActionsDemo::onExit();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void Issue1305::addSprite(float dt)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_spriteTmp->setPosition(ccp(250,250));
|
|
|
|
addChild(_spriteTmp);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1305::title()
|
|
|
|
{
|
|
|
|
return "Issue 1305";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1305::subtitle()
|
|
|
|
{
|
|
|
|
return "In two seconds you should see a message on the console. NOT BEFORE.";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1305_2::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(0);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite *spr = CCSprite::create("Images/grossini.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
spr->setPosition(ccp(200,200));
|
|
|
|
addChild(spr);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act1 = CCMoveBy::create(2 ,ccp(0, 100));
|
2012-04-19 14:35:52 +08:00
|
|
|
/* c++ can't support block, so we use CCCallFuncN instead.
|
|
|
|
id act2 = [CCCallBlock actionWithBlock:^{
|
|
|
|
NSLog(@"1st block");
|
2013-02-28 14:42:45 +08:00
|
|
|
});
|
2013-02-28 15:32:27 +08:00
|
|
|
id act3 = [CCMoveBy create:2, ccp(0, -100));
|
2012-04-19 14:35:52 +08:00
|
|
|
id act4 = [CCCallBlock actionWithBlock:^{
|
|
|
|
NSLog(@"2nd block");
|
2013-02-28 14:42:45 +08:00
|
|
|
});
|
2013-02-28 15:32:27 +08:00
|
|
|
id act5 = [CCMoveBy create:2, ccp(100, -100));
|
2012-04-19 14:35:52 +08:00
|
|
|
id act6 = [CCCallBlock actionWithBlock:^{
|
|
|
|
NSLog(@"3rd block");
|
2013-02-28 14:42:45 +08:00
|
|
|
});
|
2013-02-28 15:32:27 +08:00
|
|
|
id act7 = [CCMoveBy create:2, ccp(-100, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
id act8 = [CCCallBlock actionWithBlock:^{
|
|
|
|
NSLog(@"4th block");
|
2013-02-28 14:42:45 +08:00
|
|
|
});
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act2 = CCCallFunc::create( std::bind( &Issue1305_2::printLog1, this));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act3 = CCMoveBy::create(2, ccp(0, -100));
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act4 = CCCallFunc::create( std::bind( &Issue1305_2::printLog2, this));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act5 = CCMoveBy::create(2, ccp(100, -100));
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act6 = CCCallFunc::create( std::bind( &Issue1305_2::printLog3, this));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act7 = CCMoveBy::create(2, ccp(-100, 0));
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act8 = CCCallFunc::create( std::bind( &Issue1305_2::printLog4, this));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* actF = CCSequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-02-28 14:42:45 +08:00
|
|
|
// [spr runAction:actF);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDirector::sharedDirector()->getActionManager()->addAction(actF ,spr, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-26 04:40:37 +08:00
|
|
|
void Issue1305_2::printLog1()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("1st block");
|
|
|
|
}
|
|
|
|
|
2012-10-26 04:40:37 +08:00
|
|
|
void Issue1305_2::printLog2()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("2nd block");
|
|
|
|
}
|
|
|
|
|
2012-10-26 04:40:37 +08:00
|
|
|
void Issue1305_2::printLog3()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("3rd block");
|
|
|
|
}
|
|
|
|
|
2012-10-26 04:40:37 +08:00
|
|
|
void Issue1305_2::printLog4()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCLog("4th block");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1305_2::title()
|
|
|
|
{
|
|
|
|
return "Issue 1305 #2";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1305_2::subtitle()
|
|
|
|
{
|
|
|
|
return "See console. You should only see one message for each block";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1288::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(0);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite *spr = CCSprite::create("Images/grossini.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
spr->setPosition(ccp(100, 100));
|
|
|
|
addChild(spr);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0));
|
2013-06-19 06:06:53 +08:00
|
|
|
CCMoveBy* act2 = act1->reverse();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction* act3 = CCSequence::create(act1, act2, NULL);
|
|
|
|
CCRepeat* act4 = CCRepeat::create(act3, 2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
spr->runAction(act4);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1288::title()
|
|
|
|
{
|
|
|
|
return "Issue 1288";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1288::subtitle()
|
|
|
|
{
|
|
|
|
return "Sprite should end at the position where it started.";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1288_2::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(0);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite *spr = CCSprite::create("Images/grossini.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
spr->setPosition(ccp(100, 100));
|
|
|
|
addChild(spr);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0));
|
|
|
|
spr->runAction(CCRepeat::create(act1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1288_2::title()
|
|
|
|
{
|
|
|
|
return "Issue 1288 #2";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1288_2::subtitle()
|
|
|
|
{
|
|
|
|
return "Sprite should move 100 pixels, and stay there";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Issue1327::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
centerSprites(0);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite *spr = CCSprite::create("Images/grossini.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
spr->setPosition(ccp(100, 100));
|
|
|
|
addChild(spr);
|
|
|
|
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act1 = CCCallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy* act2 = CCRotateBy::create(0.25, 45);
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act3 = CCCallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy* act4 = CCRotateBy::create(0.25, 45);
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act5 = CCCallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy* act6 = CCRotateBy::create(0.25, 45);
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act7 = CCCallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRotateBy* act8 = CCRotateBy::create(0.25, 45);
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc* act9 = CCCallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr));
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCFiniteTimeAction* actF = CCSequence::create(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
spr->runAction(actF);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1327::title()
|
|
|
|
{
|
|
|
|
return "Issue 1327";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1327::subtitle()
|
|
|
|
{
|
|
|
|
return "See console: You should see: 0, 45, 90, 135, 180";
|
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1327::logSprRotation(CCNode* pSender)
|
|
|
|
{
|
|
|
|
CCLog("%f", ((CCSprite*)pSender)->getRotation());
|
|
|
|
}
|
|
|
|
|
2012-11-19 17:15:16 +08:00
|
|
|
//Issue1398
|
2013-02-28 14:42:45 +08:00
|
|
|
void Issue1398::incrementInteger()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_testInteger++;
|
|
|
|
CCLog("incremented to %d", _testInteger);
|
2012-11-19 17:15:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Issue1398::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
this->centerSprites(0);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_testInteger = 0;
|
|
|
|
CCLog("testInt = %d", _testInteger);
|
2012-11-19 17:15:16 +08:00
|
|
|
|
|
|
|
this->runAction(
|
|
|
|
CCSequence::create(
|
2013-06-04 03:13:24 +08:00
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"1")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"2")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"3")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"4")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"5")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"6")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"7")),
|
|
|
|
CCCallFunc::create( std::bind(&Issue1398::incrementIntegerCallback, this, (void*)"8")),
|
2012-11-19 17:15:16 +08:00
|
|
|
NULL));
|
|
|
|
}
|
|
|
|
|
2013-06-04 03:13:24 +08:00
|
|
|
void Issue1398::incrementIntegerCallback(void* data)
|
2012-11-19 17:15:16 +08:00
|
|
|
{
|
|
|
|
this->incrementInteger();
|
2013-04-19 15:47:14 +08:00
|
|
|
CCLog("%s", (char*)data);
|
2012-11-19 17:15:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1398::subtitle()
|
|
|
|
{
|
|
|
|
return "See console: You should see an 8";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue1398::title()
|
|
|
|
{
|
|
|
|
return "Issue 1398";
|
|
|
|
}
|
|
|
|
|
2012-06-11 18:25:57 +08:00
|
|
|
/** ActionCatmullRom
|
|
|
|
*/
|
|
|
|
void ActionCatmullRom::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
this->centerSprites(2);
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
//
|
|
|
|
// sprite 1 (By)
|
|
|
|
//
|
|
|
|
// startPosition can be any coordinate, but since the movement
|
|
|
|
// is relative to the Catmull Rom curve, it is better to start with (0,0).
|
|
|
|
//
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setPosition(ccp(50, 50));
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCPointArray *array = CCPointArray::create(20);
|
2012-06-11 18:25:57 +08:00
|
|
|
|
|
|
|
array->addControlPoint(ccp(0, 0));
|
|
|
|
array->addControlPoint(ccp(80, 80));
|
|
|
|
array->addControlPoint(ccp(s.width - 80, 80));
|
|
|
|
array->addControlPoint(ccp(s.width - 80, s.height - 80));
|
|
|
|
array->addControlPoint(ccp(80, s.height - 80));
|
|
|
|
array->addControlPoint(ccp(80, 80));
|
|
|
|
array->addControlPoint(ccp(s.width / 2, s.height / 2));
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCatmullRomBy *action = CCCatmullRomBy::create(3, array);
|
2012-06-11 18:25:57 +08:00
|
|
|
CCFiniteTimeAction *reverse = action->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction *seq = CCSequence::create(action, reverse, NULL);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(seq);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 2 (To)
|
|
|
|
//
|
|
|
|
// The startPosition is not important here, because it uses a "To" action.
|
|
|
|
// The initial position will be the 1st point of the Catmull Rom path
|
|
|
|
//
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCPointArray *array2 = CCPointArray::create(20);
|
2012-06-11 18:25:57 +08:00
|
|
|
|
|
|
|
array2->addControlPoint(ccp(s.width / 2, 30));
|
|
|
|
array2->addControlPoint(ccp(s.width -80, 30));
|
|
|
|
array2->addControlPoint(ccp(s.width - 80, s.height - 80));
|
|
|
|
array2->addControlPoint(ccp(s.width / 2, s.height - 80));
|
|
|
|
array2->addControlPoint(ccp(s.width / 2, 30));
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCatmullRomTo *action2 = CCCatmullRomTo::create(3, array2);
|
2012-06-11 18:25:57 +08:00
|
|
|
CCFiniteTimeAction *reverse2 = action2->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction *seq2 = CCSequence::create(action2, reverse2, NULL);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->runAction(seq2);
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_array1 = array;
|
|
|
|
_array1->retain();
|
|
|
|
_array2 = array2;
|
|
|
|
_array2->retain();
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ActionCatmullRom::~ActionCatmullRom()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_array1->release();
|
|
|
|
_array2->release();
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCatmullRom::draw()
|
|
|
|
{
|
|
|
|
ActionsDemo::draw();
|
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
// move to 50,50 since the "by" path will start at 50,50
|
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(50, 50, 0);
|
2013-06-15 14:03:30 +08:00
|
|
|
ccDrawCatmullRom(_array1, 50);
|
2013-02-28 15:32:27 +08:00
|
|
|
kmGLPopMatrix();
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
ccDrawCatmullRom(_array2,50);
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string ActionCatmullRom::title()
|
|
|
|
{
|
|
|
|
return "CatmullRomBy / CatmullRomTo";
|
|
|
|
}
|
|
|
|
|
|
|
|
string ActionCatmullRom::subtitle()
|
|
|
|
{
|
|
|
|
return "Catmull Rom spline paths. Testing reverse too";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** ActionCardinalSpline
|
|
|
|
*/
|
|
|
|
void ActionCardinalSpline::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-11 18:25:57 +08:00
|
|
|
this->centerSprites(2);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-11 18:25:57 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCPointArray *array = CCPointArray::create(20);
|
2012-06-11 18:25:57 +08:00
|
|
|
|
|
|
|
array->addControlPoint(ccp(0, 0));
|
|
|
|
array->addControlPoint(ccp(s.width/2-30, 0));
|
|
|
|
array->addControlPoint(ccp(s.width/2-30, s.height-80));
|
|
|
|
array->addControlPoint(ccp(0, s.height-80));
|
|
|
|
array->addControlPoint(ccp(0, 0));
|
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
//
|
|
|
|
// sprite 1 (By)
|
|
|
|
//
|
|
|
|
// Spline with no tension (tension==0)
|
|
|
|
//
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCardinalSplineBy *action = CCCardinalSplineBy::create(3, array, 0);
|
2012-06-11 18:25:57 +08:00
|
|
|
CCActionInterval *reverse = action->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction *seq = CCSequence::create(action, reverse, NULL);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->setPosition(ccp(50, 50));
|
|
|
|
_tamara->runAction(seq);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// sprite 2 (By)
|
|
|
|
//
|
|
|
|
// Spline with high tension (tension==1)
|
|
|
|
//
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCardinalSplineBy *action2 = CCCardinalSplineBy::create(3, array, 1);
|
2012-06-11 18:25:57 +08:00
|
|
|
CCActionInterval *reverse2 = action2->reverse();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFiniteTimeAction *seq2 = CCSequence::create(action2, reverse2, NULL);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_kathia->setPosition(ccp(s.width/2, 50));
|
|
|
|
_kathia->runAction(seq2);
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_array = array;
|
2012-06-11 18:25:57 +08:00
|
|
|
array->retain();
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionCardinalSpline::~ActionCardinalSpline()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_array->release();
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionCardinalSpline::draw()
|
|
|
|
{
|
|
|
|
ActionsDemo::draw();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
|
|
|
// move to 50,50 since the "by" path will start at 50,50
|
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(50, 50, 0);
|
2013-06-15 14:03:30 +08:00
|
|
|
ccDrawCardinalSpline(_array, 0, 100);
|
2013-02-28 15:32:27 +08:00
|
|
|
kmGLPopMatrix();
|
2012-06-11 18:25:57 +08:00
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2013-02-28 15:32:27 +08:00
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLTranslatef(s.width/2, 50, 0);
|
2013-06-15 14:03:30 +08:00
|
|
|
ccDrawCardinalSpline(_array, 1, 100);
|
2013-02-28 15:32:27 +08:00
|
|
|
kmGLPopMatrix();
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string ActionCardinalSpline::title()
|
|
|
|
{
|
2013-02-28 14:42:45 +08:00
|
|
|
return "CardinalSplineBy / CardinalSplineTo";
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string ActionCardinalSpline::subtitle()
|
|
|
|
{
|
|
|
|
return "Cardinal Spline paths. Testing different tensions for one array";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** PauseResumeActions
|
|
|
|
*/
|
2012-07-24 11:21:08 +08:00
|
|
|
|
|
|
|
PauseResumeActions::PauseResumeActions()
|
2013-06-15 14:03:30 +08:00
|
|
|
: _pausedTargets(NULL)
|
2012-07-24 11:21:08 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PauseResumeActions::~PauseResumeActions()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_pausedTargets);
|
2012-07-24 11:21:08 +08:00
|
|
|
}
|
|
|
|
|
2012-06-11 18:25:57 +08:00
|
|
|
void PauseResumeActions::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
2013-02-28 15:32:27 +08:00
|
|
|
|
2013-03-01 11:25:40 +08:00
|
|
|
this->centerSprites(3);
|
2012-06-11 18:25:57 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360)));
|
|
|
|
_grossini->runAction(CCRepeatForever::create(CCRotateBy::create(3, -360)));
|
|
|
|
_kathia->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360)));
|
2012-06-11 18:25:57 +08:00
|
|
|
|
|
|
|
this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0);
|
|
|
|
this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
string PauseResumeActions::title()
|
|
|
|
{
|
|
|
|
return "PauseResumeActions";
|
|
|
|
}
|
|
|
|
|
|
|
|
string PauseResumeActions::subtitle()
|
|
|
|
{
|
|
|
|
return "All actions pause at 3s and resume at 5s";
|
|
|
|
}
|
|
|
|
|
|
|
|
void PauseResumeActions::pause(float dt)
|
|
|
|
{
|
|
|
|
CCLog("Pausing");
|
|
|
|
CCDirector *director = CCDirector::sharedDirector();
|
2012-07-24 11:21:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_pausedTargets);
|
|
|
|
_pausedTargets = director->getActionManager()->pauseAllRunningActions();
|
|
|
|
CC_SAFE_RETAIN(_pausedTargets);
|
2012-06-11 18:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PauseResumeActions::resume(float dt)
|
|
|
|
{
|
|
|
|
CCLog("Resuming");
|
|
|
|
CCDirector *director = CCDirector::sharedDirector();
|
2013-06-15 14:03:30 +08:00
|
|
|
director->getActionManager()->resumeTargets(_pausedTargets);
|
2012-06-12 02:50:32 +08:00
|
|
|
}
|
2013-04-01 10:18:26 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ActionRemoveSelf
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void ActionRemoveSelf::onEnter()
|
|
|
|
{
|
|
|
|
ActionsDemo::onEnter();
|
|
|
|
|
|
|
|
alignSpritesLeft(1);
|
|
|
|
|
|
|
|
CCFiniteTimeAction* action = CCSequence::create(
|
|
|
|
CCMoveBy::create( 2, ccp(240,0)),
|
|
|
|
CCRotateBy::create( 2, 540),
|
|
|
|
CCScaleTo::create(1,0.1f),
|
|
|
|
CCRemoveSelf::create(),
|
|
|
|
NULL);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_grossini->runAction(action);
|
2013-04-01 10:18:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionRemoveSelf::subtitle()
|
|
|
|
{
|
|
|
|
return "Sequence: Move + Rotate + Scale + RemoveSelf";
|
|
|
|
}
|