From 5734a2d9bc6d08ced6c9ff95390d8f2d15d92dfe Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 19 Nov 2012 17:15:16 +0800 Subject: [PATCH] issue #1555: Updated ActionsTest.cpp --- .../Classes/ActionsTest/ActionsTest.cpp | 122 ++++++++++++++++++ .../TestCpp/Classes/ActionsTest/ActionsTest.h | 31 +++++ 2 files changed, 153 insertions(+) diff --git a/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp index 83b22f88b7..8c681be9a3 100644 --- a/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -25,6 +25,10 @@ CCLayer* CreateLayer(int nIndex) pLayer = new ActionRotate(); break; case ACTION_SKEW_LAYER: pLayer = new ActionSkew(); break; + case ACTION_ROTATIONAL_SKEW_LAYER: + pLayer = new ActionRotationalSkew(); break; + case ACTION_ROTATIONAL_SKEW_VS_STANDARD_SKEW_LAYER: + pLayer = new ActionRotationalSkewVSStandardSkew(); break; case ACTION_SKEWROTATE_LAYER: pLayer = new ActionSkewRotateScale(); break; case ACTION_JUMP_LAYER: @@ -81,6 +85,8 @@ CCLayer* CreateLayer(int nIndex) pLayer = new Issue1288_2(); break; case ACTION_ISSUE1327_LAYER: pLayer = new Issue1327(); break; + case ACTION_ISSUE1398_LAYER: + pLayer = new Issue1398(); break; case ACTION_CARDINALSPLINE_LAYER: pLayer = new ActionCardinalSpline(); break; case ACTION_CATMULLROM_LAYER: @@ -394,6 +400,78 @@ string ActionSkew::subtitle() return "SkewTo / SkewBy"; } +// 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(); + + m_tamara->runAction(CCSequence::create(actionTo, actionToBack, NULL)); + m_grossini->runAction(CCSequence::create(actionBy, actionByBack, NULL)); + + m_kathia->runAction(CCSequence::create(actionBy2, actionBy2->reverse(), NULL)); +} + +std::string ActionRotationalSkew::subtitle() +{ + return "RotationalSkewTo / RotationalSkewBy"; +} + + + +//ActionRotationalSkewVSStandardSkew +void ActionRotationalSkewVSStandardSkew::onEnter() +{ + ActionsDemo::onEnter(); + + m_tamara->removeFromParentAndCleanup(true); + m_grossini->removeFromParentAndCleanup(true); + m_kathia->removeFromParentAndCleanup(true); + + 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"; +} + +// ActionSkewRotateScale void ActionSkewRotateScale::onEnter() { ActionsDemo::onEnter(); @@ -1447,6 +1525,50 @@ void Issue1327::logSprRotation(CCNode* pSender) CCLog("%f", ((CCSprite*)pSender)->getRotation()); } +//Issue1398 +void Issue1398::incrementInteger() +{ + m_nTestInteger++; + CCLog("incremented to %d", m_nTestInteger); +} + +void Issue1398::onEnter() +{ + ActionsDemo::onEnter(); + this->centerSprites(0); + + m_nTestInteger = 0; + CCLog("testInt = %d", m_nTestInteger); + + this->runAction( + CCSequence::create( + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"1"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"2"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"3"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"4"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"5"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"6"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"7"), + CCCallFuncND::create(this, callfuncND_selector(Issue1398::incrementIntegerCallback), (void*)"8"), + NULL)); +} + +void Issue1398::incrementIntegerCallback(CCNode* pSender, void* data) +{ + this->incrementInteger(); + CCLog((char*)data); +} + +std::string Issue1398::subtitle() +{ + return "See console: You should see an 8"; +} + +std::string Issue1398::title() +{ + return "Issue 1398"; +} + /** ActionCatmullRom */ void ActionCatmullRom::onEnter() diff --git a/samples/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/TestCpp/Classes/ActionsTest/ActionsTest.h index eb9eac8eca..81d535b81b 100644 --- a/samples/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -14,6 +14,8 @@ enum ACTION_SCALE_LAYER, ACTION_ROTATE_LAYER, ACTION_SKEW_LAYER, + ACTION_ROTATIONAL_SKEW_LAYER, + ACTION_ROTATIONAL_SKEW_VS_STANDARD_SKEW_LAYER, ACTION_SKEWROTATE_LAYER, ACTION_JUMP_LAYER, ACTION_CARDINALSPLINE_LAYER, @@ -45,6 +47,7 @@ enum ACTION_ISSUE1288_LAYER, ACTION_ISSUE1288_2_LAYER, ACTION_ISSUE1327_LAYER, + ACTION_ISSUE1398_LAYER, ACTION_LAYER_COUNT, }; @@ -101,12 +104,28 @@ public: class ActionSkew : public ActionsDemo { +public: + virtual void onEnter(); + virtual std::string subtitle(); +}; + +class ActionRotationalSkew : public ActionsDemo +{ +public: + virtual void onEnter(); + virtual std::string subtitle(); +}; + +class ActionRotationalSkewVSStandardSkew : public ActionsDemo +{ +public: virtual void onEnter(); virtual std::string subtitle(); }; class ActionSkewRotateScale : public ActionsDemo { +public: virtual void onEnter(); virtual std::string subtitle(); }; @@ -337,6 +356,18 @@ public: void logSprRotation(CCNode* pSender); }; +class Issue1398 : public ActionsDemo +{ +public: + void incrementInteger(); + void incrementIntegerCallback(CCNode* pSender, void* data); + virtual void onEnter(); + virtual std::string subtitle(); + virtual std::string title(); +private: + int m_nTestInteger; +}; + class ActionCatmullRom : public ActionsDemo { public: