diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index ca90cf38be..7fe81f0877 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -4,6 +4,8 @@ static std::function createFunctions[] = { + CL(ActionMoveStacked), + CL(ActionManual), CL(ActionMove), CL(ActionRotate), @@ -167,7 +169,7 @@ void ActionsDemo::backCallback(Object* pSender) void ActionsDemo::centerSprites(unsigned int numberOfSprites) { - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); if( numberOfSprites == 0 ) { @@ -197,7 +199,7 @@ void ActionsDemo::centerSprites(unsigned int numberOfSprites) void ActionsDemo::alignSpritesLeft(unsigned int numberOfSprites) { - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); if( numberOfSprites == 1 ) { @@ -228,7 +230,7 @@ void ActionManual::onEnter() { ActionsDemo::onEnter(); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); _tamara->setScaleX( 2.5f); _tamara->setScaleY( -1.0f); @@ -259,11 +261,11 @@ void ActionMove::onEnter() centerSprites(3); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); - ActionInterval* actionTo = MoveTo::create(2, ccp(s.width-40, s.height-40)); - ActionInterval* actionBy = MoveBy::create(2, ccp(80,80)); - ActionInterval* actionByBack = actionBy->reverse(); + auto actionTo = MoveTo::create(2, ccp(s.width-40, s.height-40)); + auto actionBy = MoveBy::create(2, ccp(80,80)); + auto actionByBack = actionBy->reverse(); _tamara->runAction( actionTo); _grossini->runAction( Sequence::create(actionBy, actionByBack, NULL)); @@ -286,9 +288,9 @@ void ActionScale::onEnter() centerSprites(3); - ActionInterval* actionTo = ScaleTo::create(2.0f, 0.5f); - ActionInterval* actionBy = ScaleBy::create(2.0f, 1.0f, 10.0f); - ActionInterval* actionBy2 = ScaleBy::create(2.0f, 5.0f, 1.0f); + auto actionTo = ScaleTo::create(2.0f, 0.5f); + auto actionBy = ScaleBy::create(2.0f, 1.0f, 10.0f); + auto actionBy2 = ScaleBy::create(2.0f, 5.0f, 1.0f); _grossini->runAction( actionTo); _tamara->runAction( Sequence::create(actionBy, actionBy->reverse(), NULL)); @@ -311,11 +313,11 @@ void ActionSkew::onEnter() centerSprites(3); - ActionInterval *actionTo = SkewTo::create(2, 37.2f, -37.2f); - ActionInterval *actionToBack = SkewTo::create(2, 0, 0); - ActionInterval *actionBy = SkewBy::create(2, 0.0f, -90.0f); - ActionInterval *actionBy2 = SkewBy::create(2, 45.0f, 45.0f); - ActionInterval *actionByBack = actionBy->reverse(); + auto actionTo = SkewTo::create(2, 37.2f, -37.2f); + auto actionToBack = SkewTo::create(2, 0, 0); + auto actionBy = SkewBy::create(2, 0.0f, -90.0f); + auto actionBy2 = SkewBy::create(2, 45.0f, 45.0f); + auto actionByBack = actionBy->reverse(); _tamara->runAction(Sequence::create(actionTo, actionToBack, NULL)); _grossini->runAction(Sequence::create(actionBy, actionByBack, NULL)); @@ -335,16 +337,16 @@ void ActionRotationalSkew::onEnter() this->centerSprites(3); - RotateTo* actionTo = RotateTo::create(2, 37.2f, -37.2f); - RotateTo* actionToBack = RotateTo::create(2, 0, 0); - RotateBy* actionBy = RotateBy::create(2, 0.0f, -90.0f); - RotateBy* actionBy2 = RotateBy::create(2, 45.0f, 45.0f); - RotateBy* actionByBack = (RotateBy*)actionBy->reverse(); + auto actionTo = RotateTo::create(2, 37.2f, -37.2f); + auto actionToBack = RotateTo::create(2, 0, 0); + auto actionBy = RotateBy::create(2, 0.0f, -90.0f); + auto actionBy2 = RotateBy::create(2, 45.0f, 45.0f); + auto actionByBack = actionBy->reverse(); - _tamara->runAction(Sequence::create(actionTo, actionToBack, NULL)); - _grossini->runAction(Sequence::create(actionBy, actionByBack, NULL)); + _tamara->runAction( Sequence::create(actionTo, actionToBack, NULL) ); + _grossini->runAction( Sequence::create(actionBy, actionByBack, NULL) ); - _kathia->runAction(Sequence::create(actionBy2, actionBy2->reverse(), NULL)); + _kathia->runAction( Sequence::create(actionBy2, actionBy2->reverse(), NULL) ); } std::string ActionRotationalSkew::subtitle() @@ -363,21 +365,23 @@ void ActionRotationalSkewVSStandardSkew::onEnter() _grossini->removeFromParentAndCleanup(true); _kathia->removeFromParentAndCleanup(true); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); - Size boxSize = CCSizeMake(100.0f, 100.0f); + Size boxSize(100.0f, 100.0f); - LayerColor *box = LayerColor::create(ccc4(255,255,0,255)); + auto box = LayerColor::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); - LabelTTF *label = LabelTTF::create("Standard cocos2d Skew", "Marker Felt", 16); + + auto label = LabelTTF::create("Standard cocos2d Skew", "Marker Felt", 16); label->setPosition(ccp(s.width/2, s.height - 100 + label->getContentSize().height)); this->addChild(label); - SkewBy* actionTo = SkewBy::create(2, 360, 0); - SkewBy* actionToBack = SkewBy::create(2, -360, 0); + + auto actionTo = SkewBy::create(2, 360, 0); + auto actionToBack = SkewBy::create(2, -360, 0); box->runAction(Sequence::create(actionTo, actionToBack, NULL)); @@ -387,11 +391,12 @@ void ActionRotationalSkewVSStandardSkew::onEnter() box->ignoreAnchorPointForPosition(false); box->setPosition(ccp(s.width/2, s.height - 250 - box->getContentSize().height/2)); this->addChild(box); + label = LabelTTF::create("Rotational Skew", "Marker Felt", 16); label->setPosition(ccp(s.width/2, s.height - 250 + label->getContentSize().height/2)); this->addChild(label); - RotateBy* actionTo2 = RotateBy::create(2, 360, 0); - RotateBy* actionToBack2 = RotateBy::create(2, -360, 0); + auto actionTo2 = RotateBy::create(2, 360, 0); + auto actionToBack2 = RotateBy::create(2, -360, 0); box->runAction(Sequence::create(actionTo2, actionToBack2, NULL)); } std::string ActionRotationalSkewVSStandardSkew::subtitle() @@ -408,34 +413,34 @@ void ActionSkewRotateScale::onEnter() _grossini->removeFromParentAndCleanup(true); _kathia->removeFromParentAndCleanup(true); - Size boxSize = CCSizeMake(100.0f, 100.0f); + Size boxSize(100.0f, 100.0f); - LayerColor *box = LayerColor::create(ccc4(255, 255, 0, 255)); + auto box = LayerColor::create(ccc4(255, 255, 0, 255)); box->setAnchorPoint(ccp(0, 0)); box->setPosition(ccp(190, 110)); box->setContentSize(boxSize); static float markrside = 10.0f; - LayerColor *uL = LayerColor::create(ccc4(255, 0, 0, 255)); + auto uL = LayerColor::create(ccc4(255, 0, 0, 255)); box->addChild(uL); uL->setContentSize(CCSizeMake(markrside, markrside)); uL->setPosition(ccp(0.f, boxSize.height - markrside)); uL->setAnchorPoint(ccp(0, 0)); - LayerColor *uR = LayerColor::create(ccc4(0, 0, 255, 255)); + auto uR = LayerColor::create(ccc4(0, 0, 255, 255)); box->addChild(uR); uR->setContentSize(CCSizeMake(markrside, markrside)); uR->setPosition(ccp(boxSize.width - markrside, boxSize.height - markrside)); uR->setAnchorPoint(ccp(0, 0)); addChild(box); - ActionInterval *actionTo = SkewTo::create(2, 0.f, 2.f); - ActionInterval *rotateTo = RotateTo::create(2, 61.0f); - ActionInterval *actionScaleTo = ScaleTo::create(2, -0.44f, 0.47f); + auto actionTo = SkewTo::create(2, 0.f, 2.f); + auto rotateTo = RotateTo::create(2, 61.0f); + auto actionScaleTo = ScaleTo::create(2, -0.44f, 0.47f); - ActionInterval *actionScaleToBack = ScaleTo::create(2, 1.0f, 1.0f); - ActionInterval *rotateToBack = RotateTo::create(2, 0); - ActionInterval *actionToBack = SkewTo::create(2, 0, 0); + auto actionScaleToBack = ScaleTo::create(2, 1.0f, 1.0f); + auto rotateToBack = RotateTo::create(2, 0); + auto actionToBack = SkewTo::create(2, 0, 0); box->runAction(Sequence::create(actionTo, actionToBack, NULL)); box->runAction(Sequence::create(rotateTo, rotateToBack, NULL)); @@ -458,13 +463,13 @@ void ActionRotate::onEnter() centerSprites(3); - ActionInterval* actionTo = RotateTo::create( 2, 45); - ActionInterval* actionTo2 = RotateTo::create( 2, -45); - ActionInterval* actionTo0 = RotateTo::create(2 , 0); + auto actionTo = RotateTo::create( 2, 45); + auto actionTo2 = RotateTo::create( 2, -45); + auto actionTo0 = RotateTo::create(2 , 0); _tamara->runAction( Sequence::create(actionTo, actionTo0, NULL)); - ActionInterval* actionBy = RotateBy::create(2 , 360); - ActionInterval* actionByBack = actionBy->reverse(); + auto actionBy = RotateBy::create(2 , 360); + auto actionByBack = actionBy->reverse(); _grossini->runAction( Sequence::create(actionBy, actionByBack, NULL)); _kathia->runAction( Sequence::create(actionTo2, actionTo0->clone(), NULL)); @@ -486,10 +491,10 @@ void ActionJump::onEnter() centerSprites(3); - ActionInterval* actionTo = JumpTo::create(2, ccp(300,300), 50, 4); - ActionInterval* actionBy = JumpBy::create(2, ccp(300,0), 50, 4); - ActionInterval* actionUp = JumpBy::create(2, ccp(0,0), 80, 4); - ActionInterval* actionByBack = actionBy->reverse(); + auto actionTo = JumpTo::create(2, ccp(300,300), 50, 4); + auto actionBy = JumpBy::create(2, ccp(300,0), 50, 4); + auto actionUp = JumpBy::create(2, ccp(0,0), 80, 4); + auto actionByBack = actionBy->reverse(); _tamara->runAction( actionTo); _grossini->runAction( Sequence::create(actionBy, actionByBack, NULL)); @@ -509,7 +514,7 @@ void ActionBezier::onEnter() { ActionsDemo::onEnter(); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); // // startPosition can be any coordinate, but since the movement @@ -524,23 +529,23 @@ void ActionBezier::onEnter() bezier.controlPoint_2 = ccp(300, -s.height/2); bezier.endPosition = ccp(300,100); - ActionInterval* bezierForward = BezierBy::create(3, bezier); - ActionInterval* bezierBack = bezierForward->reverse(); - Action* rep = RepeatForever::create((ActionInterval*)Sequence::create( bezierForward, bezierBack, NULL)); + auto bezierForward = BezierBy::create(3, bezier); + auto bezierBack = bezierForward->reverse(); + auto rep = RepeatForever::create(Sequence::create( bezierForward, bezierBack, NULL)); // sprite 2 _tamara->setPosition(ccp(80,160)); - ccBezierConfig bezier2; + ccBezierConfig bezier2; bezier2.controlPoint_1 = ccp(100, s.height/2); bezier2.controlPoint_2 = ccp(200, -s.height/2); bezier2.endPosition = ccp(240,160); - ActionInterval* bezierTo1 = BezierTo::create(2, bezier2); + auto bezierTo1 = BezierTo::create(2, bezier2); // sprite 3 _kathia->setPosition(ccp(400,160)); - ActionInterval* bezierTo2 = BezierTo::create(2, bezier2); + auto bezierTo2 = BezierTo::create(2, bezier2); _grossini->runAction( rep); _tamara->runAction(bezierTo1); @@ -564,8 +569,8 @@ void ActionBlink::onEnter() centerSprites(2); - ActionInterval* action1 = Blink::create(2, 10); - ActionInterval* action2 = Blink::create(2, 5); + auto action1 = Blink::create(2, 10); + auto action2 = Blink::create(2, 5); _tamara->runAction( action1); _kathia->runAction(action2); @@ -588,11 +593,11 @@ void ActionFade::onEnter() centerSprites(2); _tamara->setOpacity( 0 ); - ActionInterval* action1 = FadeIn::create(1.0f); - ActionInterval* action1Back = action1->reverse(); + auto action1 = FadeIn::create(1.0f); + auto action1Back = action1->reverse(); - ActionInterval* action2 = FadeOut::create(1.0f); - ActionInterval* action2Back = action2->reverse(); + auto action2 = FadeOut::create(1.0f); + auto action2Back = action2->reverse(); _tamara->runAction( Sequence::create( action1, action1Back, NULL)); _kathia->runAction( Sequence::create( action2, action2Back, NULL)); @@ -615,9 +620,9 @@ void ActionTint::onEnter() centerSprites(2); - ActionInterval* action1 = TintTo::create(2, 255, 0, 255); - ActionInterval* action2 = TintBy::create(2, -127, -255, -127); - ActionInterval* action2Back = action2->reverse(); + auto action1 = TintTo::create(2, 255, 0, 255); + auto action2 = TintBy::create(2, -127, -255, -127); + auto action2Back = action2->reverse(); _tamara->runAction( action1); _kathia->runAction( Sequence::create( action2, action2Back, NULL)); @@ -639,7 +644,6 @@ void ActionAnimate::onEnter() centerSprites(3); - // // Manual animation // @@ -715,7 +719,7 @@ void ActionSequence::onEnter() alignSpritesLeft(1); - FiniteTimeAction* action = Sequence::create( + auto action = Sequence::create( MoveBy::create( 2, ccp(240,0)), RotateBy::create( 2, 540), NULL); @@ -741,11 +745,10 @@ void ActionSequence2::onEnter() _grossini->setVisible(false); - FiniteTimeAction* action = Sequence::create( + auto action = Sequence::create( Place::create(ccp(200,200)), Show::create(), MoveBy::create(1, ccp(100,0)), - // CC_CALLBACK_0 == std::bind( &function, instance, ...) CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback1,this)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback2,this,_grossini)), CallFunc::create( CC_CALLBACK_0(ActionSequence2::callback3,this,_grossini,(void*)0xbebabeba)), @@ -756,8 +759,8 @@ void ActionSequence2::onEnter() void ActionSequence2::callback1() { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 1 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*1,s.height/2)); addChild(label); @@ -765,8 +768,8 @@ void ActionSequence2::callback1() void ActionSequence2::callback2(Node* sender) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 2 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*2,s.height/2)); addChild(label); @@ -774,8 +777,8 @@ void ActionSequence2::callback2(Node* sender) void ActionSequence2::callback3(Node* sender, void* data) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 3 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*3,s.height/2)); addChild(label); @@ -798,18 +801,18 @@ void ActionCallFunc::onEnter() centerSprites(3); - FiniteTimeAction* action = Sequence::create( + auto action = Sequence::create( MoveBy::create(2, ccp(200,0)), - CallFunc::create(this, callfunc_selector(ActionCallFunc::callback1)), + CallFunc::create(this, callfunc_selector(ActionCallFunc::callback1)), NULL); - FiniteTimeAction* action2 = Sequence::create( + auto action2 = Sequence::create( ScaleBy::create(2 , 2), FadeOut::create(2), CallFuncN::create(this, callfuncN_selector(ActionSequence2::callback2)), NULL); - FiniteTimeAction* action3 = Sequence::create( + auto action3 = Sequence::create( RotateBy::create(3 , 360), FadeOut::create(2), CallFuncND::create(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), @@ -823,8 +826,8 @@ void ActionCallFunc::onEnter() void ActionCallFunc::callback1() { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 1 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*1,s.height/2)); addChild(label); @@ -832,8 +835,8 @@ void ActionCallFunc::callback1() void ActionCallFunc::callback2(Node* pSender) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 2 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*2,s.height/2)); addChild(label); @@ -841,8 +844,8 @@ void ActionCallFunc::callback2(Node* pSender) void ActionCallFunc::callback3(Node* pTarget, void* data) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 3 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*3,s.height/2)); addChild(label); } @@ -864,7 +867,7 @@ void ActionCallFuncND::onEnter() centerSprites(1); - FiniteTimeAction* action = Sequence::create(MoveBy::create(2.0f, ccp(200,0)), + auto action = Sequence::create(MoveBy::create(2.0f, ccp(200,0)), CallFuncND::create(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true), NULL); @@ -899,30 +902,30 @@ void ActionCallFunction::onEnter() centerSprites(3); - FiniteTimeAction* action1 = Sequence::create( - MoveBy::create(2, ccp(200,0)), - CallFunc::create( std::bind(&ActionCallFunction::callback1, this) ), - CallFunc::create( - // lambda - [&](){ - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("called:lambda callback", "Marker Felt", 16); - label->setPosition(ccp( s.width/4*1,s.height/2-40)); - this->addChild(label); - } ), - NULL); + auto action1 = Sequence::create( + MoveBy::create(2, ccp(200,0)), + CallFunc::create( std::bind(&ActionCallFunction::callback1, this) ), + CallFunc::create( + // lambda + [&](){ + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("called:lambda callback", "Marker Felt", 16); + label->setPosition(ccp( s.width/4*1,s.height/2-40)); + this->addChild(label); + } ), + NULL); - FiniteTimeAction* action2 = Sequence::create( - ScaleBy::create(2 , 2), - FadeOut::create(2), - CallFunc::create( std::bind(&ActionCallFunction::callback2, this, _tamara) ), - NULL); + auto action2 = Sequence::create( + ScaleBy::create(2 , 2), + FadeOut::create(2), + CallFunc::create( std::bind(&ActionCallFunction::callback2, this, _tamara) ), + NULL); - FiniteTimeAction* action3 = Sequence::create( - RotateBy::create(3 , 360), - FadeOut::create(2), - CallFunc::create( std::bind(&ActionCallFunction::callback3, this, _kathia, (void*)42) ), - NULL); + auto action3 = Sequence::create( + RotateBy::create(3 , 360), + FadeOut::create(2), + CallFunc::create( std::bind(&ActionCallFunction::callback3, this, _kathia, (void*)42) ), + NULL); _grossini->runAction(action1); _tamara->runAction(action2); @@ -932,8 +935,8 @@ void ActionCallFunction::onEnter() void ActionCallFunction::callback1() { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 1 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*1,s.height/2)); addChild(label); @@ -941,8 +944,8 @@ void ActionCallFunction::callback1() void ActionCallFunction::callback2(Node* sender) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 2 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*2,s.height/2)); addChild(label); @@ -952,8 +955,8 @@ void ActionCallFunction::callback2(Node* sender) void ActionCallFunction::callback3(Node* sender, void* data) { - Size s = Director::sharedDirector()->getWinSize(); - LabelTTF *label = LabelTTF::create("callback 3 called", "Marker Felt", 16); + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*3,s.height/2)); addChild(label); @@ -976,8 +979,7 @@ void ActionSpawn::onEnter() alignSpritesLeft(1); - - Action* action = Spawn::create( + auto action = Spawn::create( JumpBy::create(2, ccp(300,0), 50, 4), RotateBy::create( 2, 720), NULL); @@ -1002,7 +1004,7 @@ void ActionRepeatForever::onEnter() centerSprites(1); - FiniteTimeAction* action = Sequence::create( + auto action = Sequence::create( DelayTime::create(1), CallFunc::create( std::bind( &ActionRepeatForever::repeatForever, this, _grossini) ), NULL); @@ -1012,7 +1014,7 @@ void ActionRepeatForever::onEnter() void ActionRepeatForever::repeatForever(Node* pSender) { - RepeatForever *repeat = RepeatForever::create( RotateBy::create(1.0f, 360) ); + auto repeat = RepeatForever::create( RotateBy::create(1.0f, 360) ); pSender->runAction(repeat); } @@ -1034,11 +1036,11 @@ void ActionRotateToRepeat::onEnter() centerSprites(2); - ActionInterval* act1 = RotateTo::create(1, 90); - ActionInterval* act2 = RotateTo::create(1, 0); - ActionInterval* seq = Sequence::create(act1, act2, NULL); - Action* rep1 = RepeatForever::create(seq); - ActionInterval* rep2 = Repeat::create( seq->clone(), 10); + auto act1 = RotateTo::create(1, 90); + auto act2 = RotateTo::create(1, 0); + auto seq = Sequence::create(act1, act2, NULL); + auto rep1 = RepeatForever::create(seq); + auto rep2 = Repeat::create( seq->clone(), 10); _tamara->runAction(rep1); _kathia->runAction(rep2); @@ -1061,13 +1063,13 @@ void ActionRotateJerk::onEnter() centerSprites(2); - FiniteTimeAction* seq = Sequence::create( + auto seq = Sequence::create( RotateTo::create(0.5f, -20), RotateTo::create(0.5f, 20), NULL); - ActionInterval* rep1 = Repeat::create(seq, 10); - Action* rep2 = RepeatForever::create( (ActionInterval*) seq->clone() ); + auto rep1 = Repeat::create(seq, 10); + auto rep2 = RepeatForever::create( seq->clone() ); _tamara->runAction(rep1); _kathia->runAction(rep2); @@ -1089,8 +1091,8 @@ void ActionReverse::onEnter() alignSpritesLeft(1); - ActionInterval* jump = JumpBy::create(2, ccp(300,0), 50, 4); - FiniteTimeAction* action = Sequence::create( jump, jump->reverse(), NULL); + auto jump = JumpBy::create(2, ccp(300,0), 50, 4); + auto action = Sequence::create( jump, jump->reverse(), NULL); _grossini->runAction(action); } @@ -1112,8 +1114,8 @@ void ActionDelayTime::onEnter() alignSpritesLeft(1); - ActionInterval* move = MoveBy::create(1, ccp(150,0)); - FiniteTimeAction* action = Sequence::create( move, DelayTime::create(2), move, NULL); + auto move = MoveBy::create(1, ccp(150,0)); + auto action = Sequence::create( move, DelayTime::create(2), move, NULL); _grossini->runAction(action); } @@ -1135,10 +1137,10 @@ void ActionReverseSequence::onEnter() alignSpritesLeft(1); - ActionInterval* move1 = MoveBy::create(1, ccp(250,0)); - ActionInterval* move2 = MoveBy::create(1, ccp(0,50)); - FiniteTimeAction* seq = Sequence::create( move1, move2, move1->reverse(), NULL); - FiniteTimeAction* action = Sequence::create( seq, seq->reverse(), NULL); + auto move1 = MoveBy::create(1, ccp(250,0)); + auto move2 = MoveBy::create(1, ccp(0,50)); + auto seq = Sequence::create( move1, move2, move1->reverse(), NULL); + auto action = Sequence::create( seq, seq->reverse(), NULL); _grossini->runAction(action); } @@ -1199,12 +1201,12 @@ void ActionRepeat::onEnter() alignSpritesLeft(2); - ActionInterval* a1 = MoveBy::create(1, ccp(150,0)); - ActionInterval* action1 = Repeat::create( + auto a1 = MoveBy::create(1, ccp(150,0)); + auto action1 = Repeat::create( Sequence::create( Place::create(ccp(60,60)), a1, NULL) , 3); - Action* action2 = RepeatForever::create( - Sequence::create((ActionInterval*)(a1->clone()), a1->reverse(), NULL) + auto action2 = RepeatForever::create( + Sequence::create(a1->clone(), a1->reverse(), NULL) ); _kathia->runAction(action1); @@ -1227,20 +1229,20 @@ void ActionOrbit::onEnter() centerSprites(3); - ActionInterval* orbit1 = OrbitCamera::create(2,1, 0, 0, 180, 0, 0); - Sequence* action1 = Sequence::create( + auto orbit1 = OrbitCamera::create(2,1, 0, 0, 180, 0, 0); + auto action1 = Sequence::create( orbit1, orbit1->reverse(), NULL); - ActionInterval* orbit2 = OrbitCamera::create(2,1, 0, 0, 180, -45, 0); - Sequence* action2 = Sequence::create( + auto orbit2 = OrbitCamera::create(2,1, 0, 0, 180, -45, 0); + auto action2 = Sequence::create( orbit2, orbit2->reverse(), NULL); - ActionInterval* orbit3 = OrbitCamera::create(2,1, 0, 0, 180, 90, 0); - Sequence* action3 = Sequence::create( + auto orbit3 = OrbitCamera::create(2,1, 0, 0, 180, 90, 0); + auto action3 = Sequence::create( orbit3, orbit3->reverse(), NULL); @@ -1249,10 +1251,10 @@ void ActionOrbit::onEnter() _tamara->runAction(RepeatForever::create(action2)); _grossini->runAction(RepeatForever::create(action3)); - ActionInterval* move = MoveBy::create(3, ccp(100,-100)); - ActionInterval* move_back = move->reverse(); - Sequence* seq = Sequence::create(move, move_back, NULL); - Action* rfe = RepeatForever::create(seq); + auto move = MoveBy::create(3, ccp(100,-100)); + auto move_back = move->reverse(); + auto seq = Sequence::create(move, move_back, NULL); + auto rfe = RepeatForever::create(seq); _kathia->runAction(rfe); _tamara->runAction(rfe->clone() ); _grossini->runAction( rfe->clone() ); @@ -1273,13 +1275,13 @@ void ActionFollow::onEnter() ActionsDemo::onEnter(); centerSprites(1); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); _grossini->setPosition(ccp(-200, s.height / 2)); - ActionInterval* move = MoveBy::create(2, ccp(s.width * 3, 0)); - ActionInterval* move_back = move->reverse(); - Sequence* seq = Sequence::create(move, move_back, NULL); - Action* rep = RepeatForever::create(seq); + auto move = MoveBy::create(2, ccp(s.width * 3, 0)); + auto move_back = move->reverse(); + auto seq = Sequence::create(move, move_back, NULL); + auto rep = RepeatForever::create(seq); _grossini->runAction(rep); @@ -1288,7 +1290,7 @@ void ActionFollow::onEnter() void ActionFollow::draw() { - Size winSize = Director::sharedDirector()->getWinSize(); + auto winSize = Director::sharedDirector()->getWinSize(); float x = winSize.width*2 - 100; float y = winSize.height; @@ -1308,17 +1310,16 @@ void ActionTargeted::onEnter() centerSprites(2); - JumpBy* jump1 = JumpBy::create(2,PointZero,100,3); - JumpBy* jump2 = jump1->clone(); - RotateBy* rot1 = RotateBy::create(1, 360); - RotateBy* rot2 = rot1->clone(); + auto jump1 = JumpBy::create(2,PointZero,100,3); + auto jump2 = jump1->clone(); + auto rot1 = RotateBy::create(1, 360); + auto rot2 = rot1->clone(); - TargetedAction *t1 = TargetedAction::create(_kathia, jump2); - TargetedAction *t2 = TargetedAction::create(_kathia, rot2); + auto t1 = TargetedAction::create(_kathia, jump2); + auto t2 = TargetedAction::create(_kathia, rot2); - - Sequence* seq = (Sequence*)Sequence::create(jump1, t1, rot1, t2, NULL); - RepeatForever *always = RepeatForever::create(seq); + auto seq = Sequence::create(jump1, t1, rot1, t2, NULL); + auto always = RepeatForever::create(seq); _tamara->runAction(always); } @@ -1343,7 +1344,7 @@ void ActionStacked::onEnter() this->setTouchEnabled(true); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); this->addNewSpriteWithCoords(ccp(s.width/2, s.height/2)); } @@ -1369,18 +1370,11 @@ void ActionStacked::runActionsInSprite(Sprite *sprite) void ActionStacked::ccTouchesEnded(Set* touches, Event* event) { - SetIterator it; - Touch* touch; + for ( auto &item: *touches ) { - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (Touch*)(*it); - - if(!touch) - break; + const Touch *touch = static_cast(item); Point location = touch->getLocation(); - addNewSpriteWithCoords( location ); } } @@ -1433,8 +1427,8 @@ void ActionMoveJumpStacked::runActionsInSprite(Sprite *sprite) MoveBy::create(0.05f, ccp(-10,-2)), NULL))); - JumpBy* jump = JumpBy::create(2.0f, ccp(400,0), 100, 5); - JumpBy* jump_back = jump->reverse(); + auto jump = JumpBy::create(2.0f, ccp(400,0), 100, 5); + auto jump_back = jump->reverse(); sprite->runAction( RepeatForever::create( @@ -1451,7 +1445,7 @@ std::string ActionMoveJumpStacked::title() void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) { - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); // sprite 1 ccBezierConfig bezier; @@ -1461,7 +1455,7 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) BezierBy* bezierForward = BezierBy::create(3, bezier); BezierBy* bezierBack = bezierForward->reverse(); - Sequence* seq = Sequence::create(bezierForward, bezierBack, NULL); + auto seq = Sequence::create(bezierForward, bezierBack, NULL); RepeatForever* rep = RepeatForever::create(seq); sprite->runAction(rep); @@ -1487,7 +1481,7 @@ void ActionCatmullRomStacked::onEnter() this->centerSprites(2); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); // // sprite 1 (By) @@ -1498,7 +1492,7 @@ void ActionCatmullRomStacked::onEnter() _tamara->setPosition(ccp(50,50)); - PointArray *array = PointArray::create(20); + auto array = PointArray::create(20); array->addControlPoint(ccp(0,0)); array->addControlPoint(ccp(80,80)); @@ -1508,21 +1502,20 @@ void ActionCatmullRomStacked::onEnter() array->addControlPoint(ccp(80,80)); array->addControlPoint(ccp(s.width/2, s.height/2)); - CatmullRomBy *action = CatmullRomBy::create(3, array); - CatmullRomBy* reverse = action->reverse(); + auto action = CatmullRomBy::create(3, array); + auto reverse = action->reverse(); - Sequence *seq = Sequence::create(action, reverse, NULL); + auto seq = Sequence::create(action, reverse, NULL); _tamara->runAction(seq); _tamara->runAction( - RepeatForever::create( - Sequence::create( - MoveBy::create(0.05f, ccp(10,0)), - MoveBy::create(0.05f, ccp(-10,0)), - NULL))); - + RepeatForever::create( + Sequence::create( + MoveBy::create(0.05f, ccp(10,0)), + MoveBy::create(0.05f, ccp(-10,0)), + NULL))); // // sprite 2 (To) @@ -1531,7 +1524,7 @@ void ActionCatmullRomStacked::onEnter() // The initial position will be the 1st point of the Catmull Rom path // - PointArray *array2 = PointArray::create(20); + auto array2 = PointArray::create(20); array2->addControlPoint(ccp(s.width/2, 30)); array2->addControlPoint(ccp(s.width-80,30)); @@ -1539,21 +1532,19 @@ void ActionCatmullRomStacked::onEnter() array2->addControlPoint(ccp(s.width/2,s.height-80)); array2->addControlPoint(ccp(s.width/2, 30)); + auto action2 = CatmullRomTo::create(3, array2); + auto reverse2 = action2->reverse(); - CatmullRomTo *action2 = CatmullRomTo::create(3, array2); - CatmullRomTo* reverse2 = action2->reverse(); - - Sequence *seq2 = Sequence::create(action2, reverse2, NULL); + auto seq2 = Sequence::create(action2, reverse2, NULL); _kathia->runAction(seq2); - _kathia->runAction( - RepeatForever::create( - Sequence::create( - MoveBy::create(0.05f, ccp(10,0)), - MoveBy::create(0.05f, ccp(-10,0)), - NULL))); + RepeatForever::create( + Sequence::create( + MoveBy::create(0.05f, ccp(10,0)), + MoveBy::create(0.05f, ccp(-10,0)), + NULL))); array->retain(); @@ -1600,9 +1591,9 @@ void ActionCardinalSplineStacked::onEnter() this->centerSprites(2); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); - PointArray *array = PointArray::create(20); + auto array = PointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(s.width/2-30,0)); @@ -1616,23 +1607,21 @@ void ActionCardinalSplineStacked::onEnter() // // Spline with no tension (tension==0) // + + auto action = CardinalSplineBy::create(3, array, 0); + auto reverse = action->reverse(); - - CatmullRomBy *action = (CatmullRomBy*)CardinalSplineBy::create(3, array, 0); - CatmullRomBy* reverse = action->reverse(); - - Sequence *seq = Sequence::create(action, reverse, NULL); + auto seq = Sequence::create(action, reverse, NULL); _tamara->setPosition(ccp(50,50)); _tamara->runAction(seq); _tamara->runAction( - RepeatForever::create( - Sequence::create( - MoveBy::create(0.05f, ccp(10,0)), - MoveBy::create(0.05f, ccp(-10,0)), - NULL))); - + RepeatForever::create( + Sequence::create( + MoveBy::create(0.05f, ccp(10,0)), + MoveBy::create(0.05f, ccp(-10,0)), + NULL))); // // sprite 2 (By) @@ -1640,22 +1629,21 @@ void ActionCardinalSplineStacked::onEnter() // Spline with high tension (tension==1) // - CardinalSplineBy *action2 = CardinalSplineBy::create(3, array, 1); - CardinalSplineBy* reverse2 = action2->reverse(); + auto *action2 = CardinalSplineBy::create(3, array, 1); + auto reverse2 = action2->reverse(); - Sequence *seq2 = Sequence::create(action2, reverse2, NULL); + auto seq2 = Sequence::create(action2, reverse2, NULL); _kathia->setPosition(ccp(s.width/2,50)); _kathia->runAction(seq2); _kathia->runAction( - RepeatForever::create( - Sequence::create( - MoveBy::create(0.05f, ccp(10,0)), - MoveBy::create(0.05f, ccp(-10,0)), - NULL))); - + RepeatForever::create( + Sequence::create( + MoveBy::create(0.05f, ccp(10,0)), + MoveBy::create(0.05f, ccp(-10,0)), + NULL))); array->retain(); _array = array; @@ -1676,7 +1664,7 @@ void ActionCardinalSplineStacked::draw() ccDrawCardinalSpline(_array, 0, 100); kmGLPopMatrix(); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); kmGLPushMatrix(); kmGLTranslatef(s.width/2, 50, 0); @@ -1746,11 +1734,11 @@ void Issue1305_2::onEnter() ActionsDemo::onEnter(); centerSprites(0); - Sprite *spr = Sprite::create("Images/grossini.png"); + auto spr = Sprite::create("Images/grossini.png"); spr->setPosition(ccp(200,200)); addChild(spr); - MoveBy* act1 = MoveBy::create(2 ,ccp(0, 100)); + auto act1 = MoveBy::create(2 ,ccp(0, 100)); /* c++ can't support block, so we use CallFuncN instead. id act2 = [CallBlock actionWithBlock:^{ NSLog(@"1st block"); @@ -1769,15 +1757,15 @@ void Issue1305_2::onEnter() }); */ - CallFunc* act2 = CallFunc::create( std::bind( &Issue1305_2::printLog1, this)); - MoveBy* act3 = MoveBy::create(2, ccp(0, -100)); - CallFunc* act4 = CallFunc::create( std::bind( &Issue1305_2::printLog2, this)); - MoveBy* act5 = MoveBy::create(2, ccp(100, -100)); - CallFunc* act6 = CallFunc::create( std::bind( &Issue1305_2::printLog3, this)); - MoveBy* act7 = MoveBy::create(2, ccp(-100, 0)); - CallFunc* act8 = CallFunc::create( std::bind( &Issue1305_2::printLog4, this)); + auto act2 = CallFunc::create( std::bind( &Issue1305_2::printLog1, this)); + auto act3 = MoveBy::create(2, ccp(0, -100)); + auto act4 = CallFunc::create( std::bind( &Issue1305_2::printLog2, this)); + auto act5 = MoveBy::create(2, ccp(100, -100)); + auto act6 = CallFunc::create( std::bind( &Issue1305_2::printLog3, this)); + auto act7 = MoveBy::create(2, ccp(-100, 0)); + auto act8 = CallFunc::create( std::bind( &Issue1305_2::printLog4, this)); - FiniteTimeAction* actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL); + auto actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL); // [spr runAction:actF); Director::sharedDirector()->getActionManager()->addAction(actF ,spr, false); @@ -1825,7 +1813,7 @@ void Issue1288::onEnter() MoveBy* act1 = MoveBy::create(0.5, ccp(100, 0)); MoveBy* act2 = act1->reverse(); - FiniteTimeAction* act3 = Sequence::create(act1, act2, NULL); + auto act3 = Sequence::create(act1, act2, NULL); Repeat* act4 = Repeat::create(act3, 2); spr->runAction(act4); @@ -1846,11 +1834,11 @@ void Issue1288_2::onEnter() ActionsDemo::onEnter(); centerSprites(0); - Sprite *spr = Sprite::create("Images/grossini.png"); + auto spr = Sprite::create("Images/grossini.png"); spr->setPosition(ccp(100, 100)); addChild(spr); - MoveBy* act1 = MoveBy::create(0.5, ccp(100, 0)); + auto act1 = MoveBy::create(0.5, ccp(100, 0)); spr->runAction(Repeat::create(act1, 1)); } @@ -1870,21 +1858,21 @@ void Issue1327::onEnter() ActionsDemo::onEnter(); centerSprites(0); - Sprite *spr = Sprite::create("Images/grossini.png"); + auto spr = Sprite::create("Images/grossini.png"); spr->setPosition(ccp(100, 100)); addChild(spr); - CallFunc* act1 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); - RotateBy* act2 = RotateBy::create(0.25, 45); - CallFunc* act3 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); - RotateBy* act4 = RotateBy::create(0.25, 45); - CallFunc* act5 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); - RotateBy* act6 = RotateBy::create(0.25, 45); - CallFunc* act7 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); - RotateBy* act8 = RotateBy::create(0.25, 45); - CallFunc* act9 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); + auto act1 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); + auto act2 = RotateBy::create(0.25, 45); + auto act3 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); + auto act4 = RotateBy::create(0.25, 45); + auto act5 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); + auto act6 = RotateBy::create(0.25, 45); + auto act7 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); + auto act8 = RotateBy::create(0.25, 45); + auto act9 = CallFunc::create( std::bind(&Issue1327::logSprRotation, this, spr)); - FiniteTimeAction* actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL); + auto actF = Sequence::create(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL); spr->runAction(actF); } @@ -1955,7 +1943,7 @@ void ActionCatmullRom::onEnter() this->centerSprites(2); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); // // sprite 1 (By) @@ -1966,7 +1954,7 @@ void ActionCatmullRom::onEnter() _tamara->setPosition(ccp(50, 50)); - PointArray *array = PointArray::create(20); + auto array = PointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(80, 80)); @@ -1976,10 +1964,10 @@ void ActionCatmullRom::onEnter() array->addControlPoint(ccp(80, 80)); array->addControlPoint(ccp(s.width / 2, s.height / 2)); - CatmullRomBy *action = CatmullRomBy::create(3, array); - FiniteTimeAction *reverse = action->reverse(); + auto action = CatmullRomBy::create(3, array); + auto reverse = action->reverse(); - FiniteTimeAction *seq = Sequence::create(action, reverse, NULL); + auto seq = Sequence::create(action, reverse, NULL); _tamara->runAction(seq); @@ -1991,7 +1979,7 @@ void ActionCatmullRom::onEnter() // The initial position will be the 1st point of the Catmull Rom path // - PointArray *array2 = PointArray::create(20); + auto array2 = PointArray::create(20); array2->addControlPoint(ccp(s.width / 2, 30)); array2->addControlPoint(ccp(s.width -80, 30)); @@ -1999,10 +1987,10 @@ void ActionCatmullRom::onEnter() array2->addControlPoint(ccp(s.width / 2, s.height - 80)); array2->addControlPoint(ccp(s.width / 2, 30)); - CatmullRomTo *action2 = CatmullRomTo::create(3, array2); - FiniteTimeAction *reverse2 = action2->reverse(); + auto action2 = CatmullRomTo::create(3, array2); + auto reverse2 = action2->reverse(); - FiniteTimeAction *seq2 = Sequence::create(action2, reverse2, NULL); + auto seq2 = Sequence::create(action2, reverse2, NULL); _kathia->runAction(seq2); @@ -2049,9 +2037,9 @@ void ActionCardinalSpline::onEnter() this->centerSprites(2); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); - PointArray *array = PointArray::create(20); + auto array = PointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(s.width/2-30, 0)); @@ -2065,10 +2053,10 @@ void ActionCardinalSpline::onEnter() // Spline with no tension (tension==0) // - CardinalSplineBy *action = CardinalSplineBy::create(3, array, 0); - ActionInterval *reverse = action->reverse(); + auto action = CardinalSplineBy::create(3, array, 0); + auto reverse = action->reverse(); - FiniteTimeAction *seq = Sequence::create(action, reverse, NULL); + auto seq = Sequence::create(action, reverse, NULL); _tamara->setPosition(ccp(50, 50)); _tamara->runAction(seq); @@ -2080,9 +2068,9 @@ void ActionCardinalSpline::onEnter() // CardinalSplineBy *action2 = CardinalSplineBy::create(3, array, 1); - ActionInterval *reverse2 = action2->reverse(); + auto reverse2 = action2->reverse(); - FiniteTimeAction *seq2 = Sequence::create(action2, reverse2, NULL); + auto seq2 = Sequence::create(action2, reverse2, NULL); _kathia->setPosition(ccp(s.width/2, 50)); _kathia->runAction(seq2); @@ -2106,7 +2094,7 @@ void ActionCardinalSpline::draw() ccDrawCardinalSpline(_array, 0, 100); kmGLPopMatrix(); - Size s = Director::sharedDirector()->getWinSize(); + auto s = Director::sharedDirector()->getWinSize(); kmGLPushMatrix(); kmGLTranslatef(s.width/2, 50, 0); @@ -2190,7 +2178,7 @@ void ActionRemoveSelf::onEnter() alignSpritesLeft(1); - FiniteTimeAction* action = Sequence::create( + auto action = Sequence::create( MoveBy::create( 2, ccp(240,0)), RotateBy::create( 2, 540), ScaleTo::create(1,0.1f),