From 9fe934164609e95dbe6ca3aeb9040387ec7c8304 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 8 Jul 2013 14:38:14 -0700 Subject: [PATCH] From C++ best practices Uses static_cast<> instead of C casting. --- cocos2dx/actions/CCActionInstant.cpp | 4 +-- cocos2dx/actions/CCActionInterval.cpp | 25 +++++++-------- cocos2dx/cocoa/CCDictionary.cpp | 8 ++--- cocos2dx/label_nodes/CCLabelBMFont.cpp | 18 +++++------ cocos2dx/misc_nodes/CCClippingNode.cpp | 2 +- extensions/CCArmature/display/CCBatchNode.cpp | 2 +- .../ActionsEaseTest/ActionsEaseTest.cpp | 6 ++-- .../Classes/ActionsTest/ActionsTest.cpp | 4 +-- .../TestCpp/Classes/ActionsTest/ActionsTest.h | 2 +- .../Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp | 32 +++++++++---------- .../MotionStreakTest/MotionStreakTest.cpp | 2 +- .../Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp | 14 ++++---- .../RenderTextureTest/RenderTextureTest.cpp | 2 +- .../Classes/SchedulerTest/SchedulerTest.cpp | 6 ++-- .../TestCpp/Classes/ShaderTest/ShaderTest.cpp | 2 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- .../Classes/Texture2dTest/Texture2dTest.cpp | 2 +- 17 files changed, 65 insertions(+), 68 deletions(-) diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 588ba73cf9..eeeb1eef9e 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -276,7 +276,7 @@ bool FlipX::initWithFlipX(bool x) { void FlipX::update(float time) { CC_UNUSED_PARAM(time); - ((Sprite*) (_target))->setFlipX(_flipX); + static_cast(_target)->setFlipX(_flipX); } FlipX* FlipX::reverse() const @@ -334,7 +334,7 @@ bool FlipY::initWithFlipY(bool y) { void FlipY::update(float time) { CC_UNUSED_PARAM(time); - ((Sprite*) (_target))->setFlipY(_flipY); + static_cast(_target)->setFlipY(_flipY); } FlipY* FlipY::reverse() const diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 66fd4577ea..0f25089746 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -216,13 +216,13 @@ Sequence* Sequence::create(Array* arrayOfActions) unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = (FiniteTimeAction*)arrayOfActions->objectAtIndex(0); + FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); if (count > 1) { for (unsigned int i = 1; i < count; ++i) { - prev = createWithTwoActions(prev, (FiniteTimeAction*)arrayOfActions->objectAtIndex(i)); + prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); } } else @@ -256,9 +256,7 @@ Sequence* Sequence::clone(void) const { // no copy constructor auto a = new Sequence(); - a->initWithTwoActions((FiniteTimeAction*)(_actions[0]->clone()), - (FiniteTimeAction*)(_actions[1]->clone()) - ); + a->initWithTwoActions(_actions[0]->clone(), _actions[1]->clone() ); a->autorelease(); return a; } @@ -418,7 +416,7 @@ Repeat* Repeat::clone(void) const { // no copy constructor auto a = new Repeat(); - a->initWithAction((FiniteTimeAction*)_innerAction->clone(), _times ); + a->initWithAction( _innerAction->clone(), _times ); a->autorelease(); return a; } @@ -553,7 +551,7 @@ RepeatForever *RepeatForever::clone(void) const { // no copy constructor auto a = new RepeatForever(); - a->initWithAction((ActionInterval*)_innerAction->clone()); + a->initWithAction(_innerAction->clone()); a->autorelease(); return a; } @@ -658,12 +656,12 @@ Spawn* Spawn::create(Array *arrayOfActions) { unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = (FiniteTimeAction*)arrayOfActions->objectAtIndex(0); + FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); if (count > 1) { for (unsigned int i = 1; i < arrayOfActions->count(); ++i) { - prev = createWithTwoActions(prev, (FiniteTimeAction*)arrayOfActions->objectAtIndex(i)); + prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); } } else @@ -2506,6 +2504,7 @@ void ReverseTime::update(float time) ReverseTime* ReverseTime::reverse() const { + // XXX: This looks like a bug return (ReverseTime*)_other->clone(); } @@ -2624,7 +2623,7 @@ void Animate::stop(void) { if (_animation->getRestoreOriginalFrame() && _target) { - ((Sprite*)(_target))->setDisplayFrame(_origFrame); + static_cast(_target)->setDisplayFrame(_origFrame); } ActionInterval::stop(); @@ -2655,9 +2654,9 @@ void Animate::update(float t) float splitTime = _splitTimes->at(i); if( splitTime <= t ) { - AnimationFrame* frame = (AnimationFrame*)frames->objectAtIndex(i); + AnimationFrame* frame = static_cast(frames->objectAtIndex(i)); frameToDisplay = frame->getSpriteFrame(); - ((Sprite*)_target)->setDisplayFrame(frameToDisplay); + static_cast(_target)->setDisplayFrame(frameToDisplay); Dictionary* dict = frame->getUserInfo(); if( dict ) @@ -2685,7 +2684,7 @@ Animate* Animate::reverse() const Object* pObj = NULL; CCARRAY_FOREACH_REVERSE(pOldArray, pObj) { - AnimationFrame* pElement = (AnimationFrame*)pObj; + AnimationFrame* pElement = static_cast(pObj); if (! pElement) { break; diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 30e0ffc560..375b61a9e8 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -306,7 +306,7 @@ void Dictionary::removeObjectsForKeys(Array* pKeyArray) Object* pObj = NULL; CCARRAY_FOREACH(pKeyArray, pObj) { - String* pStr = (String*)pObj; + String* pStr = static_cast(pObj); removeObjectForKey(pStr->getCString()); } } @@ -374,11 +374,11 @@ Object* Dictionary::randomObject() if (_dictType == kDictInt) { - return objectForKey(((Integer*)key)->getValue()); + return objectForKey( static_cast(key)->getValue()); } else if (_dictType == kDictStr) { - return objectForKey(((String*)key)->getCString()); + return objectForKey( static_cast(key)->getCString()); } else { @@ -398,7 +398,7 @@ Dictionary* Dictionary::create() Dictionary* Dictionary::createWithDictionary(Dictionary* srcDict) { - Dictionary* pNewDict = (Dictionary*)srcDict->copy(); + Dictionary* pNewDict = static_cast( srcDict->copy() ); pNewDict->autorelease(); return pNewDict; } diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index f7634a1181..acbe77180e 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -73,7 +73,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) s_pConfigurations = new Dictionary(); } - pRet = (CCBMFontConfiguration*)s_pConfigurations->objectForKey(fntFile); + pRet = static_cast( s_pConfigurations->objectForKey(fntFile) ); if( pRet == NULL ) { pRet = CCBMFontConfiguration::create(fntFile); @@ -649,7 +649,7 @@ void LabelBMFont::createFontChars() Sprite *fontChar; bool hasSprite = true; - fontChar = (Sprite*)(this->getChildByTag(i)); + fontChar = static_cast( this->getChildByTag(i) ); if(fontChar ) { // Reusing previous Sprite @@ -763,7 +763,7 @@ void LabelBMFont::setString(unsigned short *newString, bool needUpdateLabel) Object* child; CCARRAY_FOREACH(_children, child) { - Node* pNode = (Node*) child; + Node* pNode = static_cast( child ); if (pNode) { pNode->setVisible(false); @@ -847,7 +847,7 @@ void LabelBMFont::setOpacityModifyRGB(bool var) Object* child; CCARRAY_FOREACH(_children, child) { - Node* pNode = (Node*) child; + Node* pNode = static_cast( child ); if (pNode) { RGBAProtocol *pRGBAProtocol = dynamic_cast(pNode); @@ -871,7 +871,7 @@ void LabelBMFont::updateDisplayedOpacity(GLubyte parentOpacity) Object* pObj; CCARRAY_FOREACH(_children, pObj) { - Sprite *item = (Sprite*)pObj; + Sprite *item = static_cast( pObj ); item->updateDisplayedOpacity(_displayedOpacity); } } @@ -885,7 +885,7 @@ void LabelBMFont::updateDisplayedColor(const Color3B& parentColor) Object* pObj; CCARRAY_FOREACH(_children, pObj) { - Sprite *item = (Sprite*)pObj; + Sprite *item = static_cast( pObj ); item->updateDisplayedColor(_displayedColor); } } @@ -946,7 +946,7 @@ void LabelBMFont::updateLabel() Sprite* characterSprite; unsigned int justSkipped = 0; - while (!(characterSprite = (Sprite*)this->getChildByTag(j + skip + justSkipped))) + while (!(characterSprite = static_cast( this->getChildByTag(j + skip + justSkipped))) ) { justSkipped++; } @@ -1118,7 +1118,7 @@ void LabelBMFont::updateLabel() int index = i + line_length - 1 + lineNumber; if (index < 0) continue; - Sprite* lastChar = (Sprite*)getChildByTag(index); + Sprite* lastChar = static_cast( getChildByTag(index) ); if ( lastChar == NULL ) continue; @@ -1144,7 +1144,7 @@ void LabelBMFont::updateLabel() index = i + j + lineNumber; if (index < 0) continue; - Sprite* characterSprite = (Sprite*)getChildByTag(index); + Sprite* characterSprite = static_cast( getChildByTag(index) ); characterSprite->setPosition(ccpAdd(characterSprite->getPosition(), ccp(shift, 0.0f))); } } diff --git a/cocos2dx/misc_nodes/CCClippingNode.cpp b/cocos2dx/misc_nodes/CCClippingNode.cpp index 3cad2614b6..ce3293f944 100644 --- a/cocos2dx/misc_nodes/CCClippingNode.cpp +++ b/cocos2dx/misc_nodes/CCClippingNode.cpp @@ -45,7 +45,7 @@ static void setProgram(Node *n, GLProgram *p) Object* pObj = NULL; CCARRAY_FOREACH(n->getChildren(), pObj) { - setProgram((Node*)pObj, p); + setProgram(static_cast(pObj), p); } } diff --git a/extensions/CCArmature/display/CCBatchNode.cpp b/extensions/CCArmature/display/CCBatchNode.cpp index a2688c4d94..91488ab342 100644 --- a/extensions/CCArmature/display/CCBatchNode.cpp +++ b/extensions/CCArmature/display/CCBatchNode.cpp @@ -105,7 +105,7 @@ void BatchNode::draw() } else { - ((Node *)object)->visit(); + static_cast(object)->visit(); } } diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp index f85835862d..1862741795 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -493,9 +493,9 @@ void SpeedTest::onEnter() void SpeedTest::altertime(float dt) { - Speed* action1 = (Speed*)(_grossini->getActionByTag(kTagAction1)); - Speed* action2 = (Speed*)(_tamara->getActionByTag(kTagAction1)); - Speed* action3 = (Speed*)(_kathia->getActionByTag(kTagAction1)); + Speed* action1 = static_cast(_grossini->getActionByTag(kTagAction1)); + Speed* action2 = static_cast(_tamara->getActionByTag(kTagAction1)); + Speed* action3 = static_cast(_kathia->getActionByTag(kTagAction1)); action1->setSpeed( CCRANDOM_MINUS1_1() * 2 ); action2->setSpeed( CCRANDOM_MINUS1_1() * 2 ); diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index a389909af1..ff413c46d6 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -1887,9 +1887,9 @@ std::string Issue1327::subtitle() return "See console: You should see: 0, 45, 90, 135, 180"; } -void Issue1327::logSprRotation(Node* pSender) +void Issue1327::logSprRotation(Sprite* pSender) { - CCLog("%f", ((Sprite*)pSender)->getRotation()); + CCLog("%f", pSender->getRotation()); } //Issue1398 diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h index fd0dfbeb8b..3f94eb1c3d 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -440,7 +440,7 @@ public: virtual void onEnter(); virtual std::string subtitle(); virtual std::string title(); - void logSprRotation(Node* pSender); + void logSprRotation(Sprite* pSender); }; class Issue1398 : public ActionsDemo diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index a4709535a0..768c2ff8af 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -93,7 +93,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() if(pObject == NULL) break; - child = (Node*)pObject; + child = static_cast(pObject); Point dstPoint = child->getPosition(); int offset = (int) (s.width/2 + 50); @@ -138,12 +138,12 @@ MenuLayerMainMenu::~MenuLayerMainMenu() void MenuLayerMainMenu::menuCallback(Object* sender) { - ((LayerMultiplex*)_parent)->switchTo(1); + static_cast(_parent)->switchTo(1); } void MenuLayerMainMenu::menuCallbackConfig(Object* sender) { - ((LayerMultiplex*)_parent)->switchTo(3); + static_cast(_parent)->switchTo(3); } void MenuLayerMainMenu::allowTouches(float dt) @@ -165,17 +165,17 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) void MenuLayerMainMenu::menuCallback2(Object* sender) { - ((LayerMultiplex*)_parent)->switchTo(2); + static_cast(_parent)->switchTo(2); } void MenuLayerMainMenu::menuCallbackPriorityTest(Object* pSender) { - ((LayerMultiplex*)_parent)->switchTo(4); + static_cast(_parent)->switchTo(4); } void MenuLayerMainMenu::menuCallbackBugsTest(Object *pSender) { - ((LayerMultiplex*)_parent)->switchTo(5); + static_cast(_parent)->switchTo(5); } void MenuLayerMainMenu::onQuit(Object* sender) @@ -186,7 +186,7 @@ void MenuLayerMainMenu::onQuit(Object* sender) void MenuLayerMainMenu::menuMovingCallback(Object *pSender) { - ((LayerMultiplex*)_parent)->switchTo(6); + static_cast(_parent)->switchTo(6); } //------------------------------------------------------------------ @@ -230,7 +230,7 @@ void MenuLayer2::alignMenusH() { for(int i=0;i<2;i++) { - Menu *menu = (Menu*)getChildByTag(100+i); + Menu *menu = static_cast( getChildByTag(100+i) ); menu->setPosition( _centeredMenu ); if(i==0) { @@ -254,7 +254,7 @@ void MenuLayer2::alignMenusV() { for(int i=0;i<2;i++) { - Menu *menu = (Menu*)getChildByTag(100+i); + Menu *menu = static_cast( getChildByTag(100+i) ); menu->setPosition( _centeredMenu ); if(i==0) { @@ -275,12 +275,12 @@ void MenuLayer2::alignMenusV() void MenuLayer2::menuCallback(Object* sender) { - ((LayerMultiplex*)_parent)->switchTo(0); + static_cast(_parent)->switchTo(0); } void MenuLayer2::menuCallbackOpacity(Object* sender) { - Menu* menu = (Menu*)(((Node*)(sender))->getParent()); + Menu* menu = static_cast( static_cast(sender)->getParent() ); GLubyte opacity = menu->getOpacity(); if( opacity == 128 ) menu->setOpacity(255); @@ -315,7 +315,7 @@ MenuLayer3::MenuLayer3() _disabledItem->stopAllActions(); }); MenuItemFont* item2 = MenuItemFont::create("--- Go Back ---", [&](Object *sender) { - ((LayerMultiplex*)_parent)->switchTo(0); + static_cast(_parent)->switchTo(0); }); Sprite *spriteNormal = Sprite::create(s_MenuItem, CCRectMake(0,23*2,115,23)); @@ -454,7 +454,7 @@ void MenuLayer4::menuCallback(Object* sender) void MenuLayer4::backCallback(Object* sender) { - ((LayerMultiplex*)_parent)->switchTo(0); + static_cast(_parent)->switchTo(0); } MenuLayerPriorityTest::MenuLayerPriorityTest() @@ -511,7 +511,7 @@ MenuLayerPriorityTest::~MenuLayerPriorityTest() void MenuLayerPriorityTest::menuCallback(Object* pSender) { - ((LayerMultiplex*)_parent)->switchTo(0); + static_cast(_parent)->switchTo(0); // [[Director sharedDirector] popScene]; } @@ -530,9 +530,9 @@ BugsTest::BugsTest() menu->setPosition(ccp(s.width/2, s.height/2)); } -void BugsTest::issue1410MenuCallback(cocos2d::Object *pSender) +void BugsTest::issue1410MenuCallback(Object *sender) { - Menu *menu = (Menu*)((MenuItem*)pSender)->getParent(); + Menu *menu = static_cast( static_cast(sender)->getParent() ); menu->setTouchEnabled(false); menu->setTouchEnabled(true); diff --git a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp index a1ca08f838..24612c97fe 100644 --- a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -92,7 +92,7 @@ void MotionStreakTest2::onEnter() void MotionStreakTest2::ccTouchesMoved(Set* touches, Event* event) { - Touch* touch = (Touch*) touches->anyObject(); + Touch* touch = static_cast( touches->anyObject() ); Point touchLocation = touch->getLocation(); diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index c52174e1ba..ff0f390b31 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -204,7 +204,7 @@ Test4::Test4() void Test4::delay2(float dt) { - Sprite* node = (Sprite*)(getChildByTag(2)); + Sprite* node = static_cast(getChildByTag(2)); Action* action1 = RotateBy::create(1, 360); node->runAction(action1); } @@ -358,8 +358,8 @@ void StressTest1::shouldNotCrash(float dt) Size s = Director::sharedDirector()->getWinSize(); // if the node has timers, it crashes - Node* explosion = ParticleSun::create(); - ((ParticleSun*)explosion)->setTexture(TextureCache::sharedTextureCache()->addImage("Images/fire.png")); + ParticleSun* explosion = ParticleSun::create(); + explosion->setTexture(TextureCache::sharedTextureCache()->addImage("Images/fire.png")); // if it doesn't, it works Ok. // CocosNode *explosion = [Sprite create:@"grossinis_sister2.png"); @@ -425,7 +425,7 @@ StressTest2::StressTest2() void StressTest2::shouldNotLeak(float dt) { unschedule( schedule_selector(StressTest2::shouldNotLeak) ); - Layer* sublayer = (Layer*)getChildByTag(kTagSprite1); + Layer* sublayer = static_cast( getChildByTag(kTagSprite1) ); sublayer->removeAllChildrenWithCleanup(true); } @@ -753,9 +753,7 @@ ConvertToNode::ConvertToNode() point->setPosition(sprite->getPosition()); - RepeatForever* copy = (RepeatForever*) action->copy(); - copy->autorelease(); - sprite->runAction(copy); + sprite->runAction( action->clone() ); addChild(sprite, i); } } @@ -764,7 +762,7 @@ void ConvertToNode::ccTouchesEnded(Set* touches, Event *event) { for( SetIterator it = touches->begin(); it != touches->end(); ++it) { - Touch* touch = (Touch*)(*it); + Touch* touch = static_cast(*it); Point location = touch->getLocation(); for( int i = 0; i < 3; i++) diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index ba7e6ff817..1d9fe67bc0 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -178,7 +178,7 @@ RenderTextureSave::~RenderTextureSave() void RenderTextureSave::ccTouchesMoved(Set* touches, Event* event) { - Touch *touch = (Touch *)touches->anyObject(); + Touch *touch = static_cast( touches->anyObject() ); Point start = touch->getLocation(); Point end = touch->getPreviousLocation(); diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 78472c7eb5..d664884a8f 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -699,7 +699,7 @@ void SchedulerUpdate::removeUpdates(float dt) Object* pObject; CCARRAY_FOREACH(children, pObject) { - pNode = (Node*)pObject; + pNode = static_cast(pObject); if (! pNode) { @@ -876,7 +876,7 @@ ControlSlider* SchedulerTimeScale::sliderCtl() void SchedulerTimeScale::sliderAction(Object* pSender, ControlEvent controlEvent) { - ControlSlider* pSliderCtl = (ControlSlider*)pSender; + ControlSlider* pSliderCtl = static_cast(pSender); float scale; scale = pSliderCtl->getValue(); @@ -970,7 +970,7 @@ void TwoSchedulers::sliderAction(Object* sender, ControlEvent controlEvent) { float scale; - ControlSlider *slider = (ControlSlider*) sender; + ControlSlider *slider = static_cast(sender); scale = slider->getValue(); if( sender == sliderCtl1 ) diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index a0b6d0713a..a4df60d99c 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -684,7 +684,7 @@ void ShaderRetroEffect::update(float dt) Object* pObj = NULL; CCARRAY_FOREACH(pArray, pObj) { - Sprite *sprite = (Sprite*)pObj; + Sprite *sprite = static_cast(pObj); i++; Point oldPosition = sprite->getPosition(); sprite->setPosition(ccp( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 )); diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 5317098242..866c81b0b9 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -68cd6c48fec5f50c0f98d427b8e677fb956a41eb \ No newline at end of file +7883471eada76dffb69780d3e2a2d39d61ae4725 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 1a128309dd..6394ac1c9f 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -1495,7 +1495,7 @@ void TextureAsync::loadImages(float dt) void TextureAsync::imageLoaded(Object* pObj) { - Texture2D* tex = (Texture2D*)pObj; + Texture2D* tex = static_cast(pObj); Director *director = Director::sharedDirector(); //CCAssert( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread");