issue #85:remove the using of dynamic_cast()

This commit is contained in:
Ming 2010-08-31 03:20:37 +00:00
parent b9587a7062
commit 39c6ebf503
27 changed files with 219 additions and 132 deletions

View File

@ -623,24 +623,32 @@ void CCDirector::end(void)
void CCDirector::setNextScene(void) void CCDirector::setNextScene(void)
{ {
bool runningIsTransition = dynamic_cast<CCTransitionScene *>(m_pRunningScene) != NULL; // bool runningIsTransition = dynamic_cast<CCTransitionScene *>(m_pRunningScene) != NULL;
bool newIsTransition = dynamic_cast<CCTransitionScene *>(m_pNextScene) != NULL; // bool newIsTransition = dynamic_cast<CCTransitionScene *>(m_pNextScene) != NULL;
ccSceneFlag runningSceneType = ccNormalScene;
ccSceneFlag newSceneType = m_pNextScene->getSceneType();
if (m_pRunningScene)
{
runningSceneType = m_pRunningScene->getSceneType();
}
// If it is not a transition, call onExit/cleanup // If it is not a transition, call onExit/cleanup
if (! newIsTransition) /*if (! newIsTransition)*/
{ if (! (newSceneType & ccTransitionScene))
if (m_pRunningScene) {
{ if (m_pRunningScene)
m_pRunningScene->onExit(); {
} m_pRunningScene->onExit();
}
// issue #709. the root node (scene) should receive the cleanup message too
// otherwise it might be leaked. // issue #709. the root node (scene) should receive the cleanup message too
if (m_bSendCleanupToScene && m_pRunningScene) // otherwise it might be leaked.
{ if (m_bSendCleanupToScene && m_pRunningScene)
m_pRunningScene->cleanup(); {
} m_pRunningScene->cleanup();
} }
}
if (m_pRunningScene) if (m_pRunningScene)
{ {
@ -650,7 +658,8 @@ void CCDirector::setNextScene(void)
m_pNextScene->retain(); m_pNextScene->retain();
m_pNextScene = NULL; m_pNextScene = NULL;
if (! runningIsTransition && m_pRunningScene) /*if (! runningIsTransition && m_pRunningScene)*/
if (! (runningSceneType & ccTransitionScene) && m_pRunningScene)
{ {
m_pRunningScene->onEnter(); m_pRunningScene->onEnter();
m_pRunningScene->onEnterTransitionDidFinish(); m_pRunningScene->onEnterTransitionDidFinish();

View File

@ -255,7 +255,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol
{ {
for (unsigned int i = 0; i < pElement->timers->num; ++i) for (unsigned int i = 0; i < pElement->timers->num; ++i)
{ {
CCTimer *pTimer = static_cast<CCTimer*>(pElement->timers->arr[i]); CCTimer *pTimer = (CCTimer*)(pElement->timers->arr[i]);
if (pfnSelector == pTimer->m_pfnSelector) if (pfnSelector == pTimer->m_pfnSelector)
{ {
@ -570,7 +570,7 @@ void CCScheduler::tick(ccTime dt)
// The 'timers' array may change while inside this loop // The 'timers' array may change while inside this loop
for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex)) for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex))
{ {
elt->currentTimer = static_cast<CCTimer*>(elt->timers->arr[elt->timerIndex]); elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]);
elt->currentTimerSalvaged = false; elt->currentTimerSalvaged = false;
elt->currentTimer->update(dt); elt->currentTimer->update(dt);

View File

@ -400,7 +400,7 @@ void CCActionManager::update(cocos2d::ccTime dt)
// elt, at this moment, is still valid // elt, at this moment, is still valid
// so it is safe to ask this here (issue #490) // so it is safe to ask this here (issue #490)
elt = static_cast<tHashElement*>(elt->hh.next); elt = (tHashElement*)(elt->hh.next);
// only delete currentTarget if no actions were scheduled during the cycle (issue #481) // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
if (m_bCurrentTargetSalvaged && m_pCurrentTarget->actions->num == 0) if (m_bCurrentTargetSalvaged && m_pCurrentTarget->actions->num == 0)

View File

@ -69,7 +69,7 @@ NSObject* CCIntervalAction::copyWithZone(NSZone *pZone)
if(pZone && pZone->m_pCopyObject) if(pZone && pZone->m_pCopyObject)
{ {
//in case of being called at sub class //in case of being called at sub class
pCopy = static_cast<CCIntervalAction*>(pZone->m_pCopyObject); pCopy = (CCIntervalAction*)(pZone->m_pCopyObject);
} }
else else
{ {
@ -215,8 +215,8 @@ NSObject* CCSequence::copyWithZone(NSZone *pZone)
__super::copyWithZone(pZone); __super::copyWithZone(pZone);
pCopy->initOneTwo(static_cast<CCFiniteTimeAction*>(m_pActions[0]->copy()->autorelease()), pCopy->initOneTwo((CCFiniteTimeAction*)(m_pActions[0]->copy()->autorelease()),
static_cast<CCFiniteTimeAction*>(m_pActions[1]->copy()->autorelease())); (CCFiniteTimeAction*)(m_pActions[1]->copy()->autorelease()));
CCX_SAFE_DELETE(pNewZone); CCX_SAFE_DELETE(pNewZone);
return pCopy; return pCopy;
@ -1365,10 +1365,12 @@ NSObject* CCFadeIn::copyWithZone(cocos2d::NSZone *pZone)
void CCFadeIn::update(cocos2d::ccTime time) void CCFadeIn::update(cocos2d::ccTime time)
{ {
// because we can not use dynamic_cast(), so we cast in c style. CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
// Is it sprite? can it be other node? if (pRGBAProtocol)
/* dynamic_cast<CCRGBAProtocol*>(m_pTarget)->setOpacity((GLubyte)(255 * time));*/ {
((CCSprite *)(m_pTarget))->setOpacity((GLubyte)(255 * time)); pRGBAProtocol->setOpacity((GLubyte)(255 * time));
}
/*m_pTarget->setOpacity((GLubyte)(255 * time));*/
} }
CCIntervalAction* CCFadeIn::reverse(void) CCIntervalAction* CCFadeIn::reverse(void)
@ -1413,10 +1415,12 @@ NSObject* CCFadeOut::copyWithZone(cocos2d::NSZone *pZone)
void CCFadeOut::update(cocos2d::ccTime time) void CCFadeOut::update(cocos2d::ccTime time)
{ {
// because we can not use dynamic_cast(), so we cast in c style. CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
// Is it sprite? can it be other node? if (pRGBAProtocol)
// dynamic_cast<CCRGBAProtocol*>(m_pTarget)->setOpacity(GLubyte(255 * (1 - time))); {
((CCSprite *)m_pTarget)->setOpacity((GLubyte)(255 * (1 - time))); pRGBAProtocol->setOpacity(GLubyte(255 * (1 - time)));
}
/*m_pTarget->setOpacity(GLubyte(255 * (1 - time)));*/
} }
CCIntervalAction* CCFadeOut::reverse(void) CCIntervalAction* CCFadeOut::reverse(void)
@ -1474,12 +1478,22 @@ void CCFadeTo::startWithTarget(CCNode *pTarget)
{ {
__super::startWithTarget(pTarget); __super::startWithTarget(pTarget);
m_fromOpacity = ((CCRGBAProtocol*)(pTarget))->getOpacity(); CCRGBAProtocol *pRGBAProtocol = pTarget->convertToRGBAProtocol();
if (pRGBAProtocol)
{
m_fromOpacity = pRGBAProtocol->getOpacity();
}
/*m_fromOpacity = pTarget->getOpacity();*/
} }
void CCFadeTo::update(cocos2d::ccTime time) void CCFadeTo::update(cocos2d::ccTime time)
{ {
((CCRGBAProtocol*)(m_pTarget))->setOpacity((GLubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time)); CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setOpacity((GLubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));
}
/*m_pTarget->setOpacity((GLubyte)(m_fromOpacity + (m_toOpacity - m_fromOpacity) * time));*/
} }
// //
@ -1531,22 +1545,23 @@ NSObject* CCTintTo::copyWithZone(cocos2d::NSZone *pZone)
void CCTintTo::startWithTarget(CCNode *pTarget) void CCTintTo::startWithTarget(CCNode *pTarget)
{ {
__super::startWithTarget(pTarget); __super::startWithTarget(pTarget);
CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
// because we can not use dynamic_cast(), so we cast in c style. if (pRGBAProtocol)
// Is it sprite? can it be other node? {
/*m_from = dynamic_cast<CCRGBAProtocol*>(pTarget)->getColor();*/ m_from = pRGBAProtocol->getColor();
m_from = ((CCSprite *)(pTarget))->getColor(); }
/*m_from = pTarget->getColor();*/
} }
void CCTintTo::update(cocos2d::ccTime time) void CCTintTo::update(cocos2d::ccTime time)
{ {
// because we can not use dynamic_cast(), so we cast in c style. CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
// Is it sprite? can it be other node? if (pRGBAProtocol)
/*CCRGBAProtocol *pTn = dynamic_cast<CCRGBAProtocol*>(m_pTarget);*/ {
CCSprite *pTn = (CCSprite *)(m_pTarget); pRGBAProtocol->setColor(ccc3(GLubyte(m_from.r + (m_to.r - m_from.r) * time),
pTn->setColor(ccc3(GLubyte(m_from.r + (m_to.r - m_from.r) * time), (GLbyte)(m_from.g + (m_to.g - m_from.g) * time),
(GLbyte)(m_from.g + (m_to.g - m_from.g) * time), (GLbyte)(m_from.b + (m_to.b - m_from.b) * time)));
(GLbyte)(m_from.b + (m_to.b - m_from.b) * time))); }
} }
// //
@ -1602,17 +1617,25 @@ void CCTintBy::startWithTarget(CCNode *pTarget)
{ {
__super::startWithTarget(pTarget); __super::startWithTarget(pTarget);
ccColor3B color = ((CCRGBAProtocol*)(pTarget))->getColor(); CCRGBAProtocol *pRGBAProtocol = pTarget->convertToRGBAProtocol();
m_fromR = color.r; if (pRGBAProtocol)
m_fromG = color.g; {
m_fromB = color.b; ccColor3B color = pRGBAProtocol->getColor();
m_fromR = color.r;
m_fromG = color.g;
m_fromB = color.b;
}
} }
void CCTintBy::update(cocos2d::ccTime time) void CCTintBy::update(cocos2d::ccTime time)
{ {
((CCRGBAProtocol*)(m_pTarget))->setColor(ccc3((GLubyte)(m_fromR + m_deltaR * time), CCRGBAProtocol *pRGBAProtocol = m_pTarget->convertToRGBAProtocol();
(GLubyte)(m_fromG + m_deltaG * time), if (pRGBAProtocol)
(GLubyte)(m_fromB + m_deltaB * time))); {
pRGBAProtocol->setColor(ccc3((GLubyte)(m_fromR + m_deltaR * time),
(GLubyte)(m_fromG + m_deltaG * time),
(GLubyte)(m_fromB + m_deltaB * time)));
}
} }
CCIntervalAction* CCTintBy::reverse(void) CCIntervalAction* CCTintBy::reverse(void)
@ -1739,7 +1762,7 @@ void CCReverseTime::update(cocos2d::ccTime time)
CCIntervalAction* CCReverseTime::reverse(void) CCIntervalAction* CCReverseTime::reverse(void)
{ {
return static_cast<CCIntervalAction*>(m_pOther->copy()->autorelease()); return (CCIntervalAction*)(m_pOther->copy()->autorelease());
} }
// //

View File

@ -82,15 +82,15 @@ CCAtlasNode * CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int
void CCAtlasNode::calculateMaxItems() void CCAtlasNode::calculateMaxItems()
{ {
CGSize s = m_pTextureAtlas->getTexture()->getContentSize(); CGSize s = m_pTextureAtlas->getTexture()->getContentSize();
m_nItemsPerColumn = static_cast<int>(s.height / m_nItemHeight); m_nItemsPerColumn = (int)(s.height / m_nItemHeight);
m_nItemsPerRow = static_cast<int>(s.width / m_nItemWidth); m_nItemsPerRow = (int)(s.width / m_nItemWidth);
} }
void CCAtlasNode:: calculateTexCoordsSteps() void CCAtlasNode:: calculateTexCoordsSteps()
{ {
CCTexture2D *texture = m_pTextureAtlas->getTexture(); CCTexture2D *texture = m_pTextureAtlas->getTexture();
m_fTexStepX = m_nItemWidth / static_cast<float>(texture->getPixelsWide()); m_fTexStepX = m_nItemWidth / (float)(texture->getPixelsWide());
m_fTexStepY = m_nItemHeight / static_cast<float>(texture->getPixelsHigh()); m_fTexStepY = m_nItemHeight / (float)(texture->getPixelsHigh());
} }
void CCAtlasNode::updateAtlasValues() void CCAtlasNode::updateAtlasValues()

View File

@ -87,6 +87,8 @@ public:
virtual void draw(); virtual void draw();
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
// CC Texture protocol // CC Texture protocol
// returns the used texture // returns the used texture

View File

@ -162,6 +162,8 @@ namespace cocos2d{
// super method // super method
virtual void setString(const char *label); virtual void setString(const char *label);
virtual void setAnchorPoint(CGPoint var); virtual void setAnchorPoint(CGPoint var);
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
#if CC_BITMAPFONTATLAS_DEBUG_DRAW #if CC_BITMAPFONTATLAS_DEBUG_DRAW
virtual void draw(); virtual void draw();
#endif // CC_BITMAPFONTATLAS_DEBUG_DRAW #endif // CC_BITMAPFONTATLAS_DEBUG_DRAW

View File

@ -55,6 +55,8 @@ namespace cocos2d{
* @warning Changing the string is as expensive as creating a new CCLabel. To obtain better performance use CCLabelAtlas * @warning Changing the string is as expensive as creating a new CCLabel. To obtain better performance use CCLabelAtlas
*/ */
virtual void setString(const char *label); virtual void setString(const char *label);
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
protected: protected:
CGSize m_tDimensions; CGSize m_tDimensions;
UITextAlignment m_eAlignment; UITextAlignment m_eAlignment;

View File

@ -53,6 +53,8 @@ namespace cocos2d{
virtual void updateAtlasValues(); virtual void updateAtlasValues();
virtual void setString(const char *label); virtual void setString(const char *label);
virtual void draw(); virtual void draw();
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
protected: protected:
// string to render // string to render
std::string m_sString; std::string m_sString;

View File

@ -130,6 +130,8 @@ public:
/** BlendFunction. Conforms to CCBlendProtocol protocol */ /** BlendFunction. Conforms to CCBlendProtocol protocol */
CCX_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) CCX_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc)
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
private : private :
void updateColor(); void updateColor();
}; };

View File

@ -90,6 +90,8 @@ namespace cocos2d{
virtual ccColor3B getColor(void); virtual ccColor3B getColor(void);
virtual void setColor(ccColor3B color); virtual void setColor(ccColor3B color);
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
private: private:
CCMenuItem* itemForTouch(CCTouch * touch); CCMenuItem* itemForTouch(CCTouch * touch);

View File

@ -107,6 +107,8 @@ namespace cocos2d{
virtual GLubyte getOpacity(); virtual GLubyte getOpacity();
virtual void setColor(ccColor3B color); virtual void setColor(ccColor3B color);
virtual ccColor3B getColor(); virtual ccColor3B getColor();
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
protected: protected:
ccColor3B m_tColorBackup; ccColor3B m_tColorBackup;
float m_fOriginalScale; float m_fOriginalScale;
@ -189,6 +191,8 @@ namespace cocos2d{
virtual ccColor3B getColor(){return ccBLACK;} virtual ccColor3B getColor(){return ccBLACK;}
virtual void setOpacity(GLubyte opacity){} virtual void setOpacity(GLubyte opacity){}
virtual GLubyte getOpacity(){return 0;} virtual GLubyte getOpacity(){return 0;}
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
}; };
/** CCMenuItemImage accepts images as items. /** CCMenuItemImage accepts images as items.
@ -251,6 +255,8 @@ namespace cocos2d{
virtual void selected(); virtual void selected();
virtual void unselected(); virtual void unselected();
virtual void setIsEnabled(bool var); virtual void setIsEnabled(bool var);
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
}; };
} }

View File

@ -39,6 +39,8 @@ class CCGridBase;
class CGPoint; class CGPoint;
class CCTouch; class CCTouch;
class CCAction; class CCAction;
class CCRGBAProtocol;
class CCLabelProtocol;
enum { enum {
kCCNodeTagInvalid = -1, kCCNodeTagInvalid = -1,
@ -446,6 +448,8 @@ public:
virtual void selectorProtocolRetain(void); virtual void selectorProtocolRetain(void);
virtual void selectorProtocolRelease(void); virtual void selectorProtocolRelease(void);
virtual CCRGBAProtocol* convertToRGBAProtocol(void) { return NULL; }
virtual CCLabelProtocol* convertToLabelProtocol(void) { return NULL; }
// transformation methods // transformation methods

View File

@ -40,6 +40,12 @@ additional logic.
It is a good practice to use and CCScene as the parent of all your nodes. It is a good practice to use and CCScene as the parent of all your nodes.
*/ */
typedef enum
{
ccNormalScene = 1 << 0,
ccTransitionScene = 1 << 1,
} ccSceneFlag;
class CCX_DLL CCScene : public CCNode class CCX_DLL CCScene : public CCNode
{ {
public: public:
@ -47,8 +53,11 @@ public:
virtual ~CCScene(); virtual ~CCScene();
bool init(); bool init();
static CCScene *node(void); static CCScene *node(void);
inline ccSceneFlag getSceneType(void) { return m_eSceneType; }
protected:
ccSceneFlag m_eSceneType;
}; };
}//namespace cocos2d }//namespace cocos2d
#endif // __CCSCENE_H__ #endif // __CCSCENE_H__

View File

@ -89,7 +89,7 @@ typedef enum {
* - But the rendering will be slower: 1 draw per children. * - But the rendering will be slower: 1 draw per children.
* *
*/ */
class CCX_DLL CCSprite : public CCNode, public CCTextureProtocol class CCX_DLL CCSprite : public CCNode, public CCTextureProtocol, public CCRGBAProtocol
{ {
public: public:
virtual void draw(void); virtual void draw(void);
@ -232,6 +232,8 @@ public:
virtual void setIsOpacityModifyRGB(bool bValue); virtual void setIsOpacityModifyRGB(bool bValue);
virtual bool getIsOpacityModifyRGB(void); virtual bool getIsOpacityModifyRGB(void);
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol *)this; }
// CCTextureProtocol // CCTextureProtocol
virtual void setTexture(CCTexture2D *texture); virtual void setTexture(CCTexture2D *texture);
virtual CCTexture2D* getTexture(void); virtual CCTexture2D* getTexture(void);

View File

@ -416,7 +416,7 @@ namespace cocos2d{
CCSprite *fontChar; CCSprite *fontChar;
fontChar = dynamic_cast<CCSprite*>(this->getChildByTag(i)); fontChar = (CCSprite*)(this->getChildByTag(i));
if( ! fontChar ) if( ! fontChar )
{ {
fontChar = new CCSprite(); fontChar = new CCSprite();
@ -488,7 +488,7 @@ namespace cocos2d{
NSMutableArray<CCNode*>::NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it) for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
{ {
(dynamic_cast<CCSprite*>(*it))->setColor(m_tColor); ((CCSprite*)(*it))->setColor(m_tColor);
} }
} }
} }
@ -505,7 +505,11 @@ namespace cocos2d{
NSMutableArray<CCNode*>::NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it) for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
{ {
(dynamic_cast<CCRGBAProtocol*>(*it))->setOpacity(m_cOpacity); CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setOpacity(m_cOpacity);
}
} }
} }
} }
@ -521,7 +525,11 @@ namespace cocos2d{
NSMutableArray<CCNode*>::NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it) for(it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
{ {
(dynamic_cast<CCRGBAProtocol*>(*it))->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB);
}
} }
} }
} }

View File

@ -107,8 +107,8 @@ void CCLayer::setIsTouchEnabled(bool enabled)
else else
{ {
// have problems? // have problems?
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCTargetedTouchDelegate*>(this)); CCTouchDispatcher::getSharedDispatcher()->removeDelegate((CCTargetedTouchDelegate*)(this));
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCStandardTouchDelegate*>(this)); CCTouchDispatcher::getSharedDispatcher()->removeDelegate((CCStandardTouchDelegate*)(this));
} }
} }
} }
@ -157,8 +157,8 @@ void CCLayer::onExit()
{ {
if( m_bIsTouchEnabled ) if( m_bIsTouchEnabled )
{ {
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCTargetedTouchDelegate*>(this)); CCTouchDispatcher::getSharedDispatcher()->removeDelegate((CCTargetedTouchDelegate*)(this));
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCStandardTouchDelegate*>(this)); CCTouchDispatcher::getSharedDispatcher()->removeDelegate((CCStandardTouchDelegate*)(this));
} }
/** /**
if( isAccelerometerEnabled ) if( isAccelerometerEnabled )

View File

@ -32,6 +32,7 @@ CCScene::CCScene()
{ {
m_bIsRelativeAnchorPoint = false; m_bIsRelativeAnchorPoint = false;
m_tAnchorPoint = ccp(0.5f, 0.5f); m_tAnchorPoint = ccp(0.5f, 0.5f);
m_eSceneType = ccNormalScene;
} }
CCScene::~CCScene() CCScene::~CCScene()

View File

@ -80,6 +80,7 @@ CCTransitionScene * CCTransitionScene::initWithDuration(ccTime t, CCScene *scene
m_pInScene->retain(); m_pInScene->retain();
m_pOutScene = CCDirector::getSharedDirector()->getRunningScene(); m_pOutScene = CCDirector::getSharedDirector()->getRunningScene();
m_pOutScene->retain(); m_pOutScene->retain();
m_eSceneType = ccTransitionScene;
NSAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" ); NSAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" );
@ -229,7 +230,7 @@ void CCRotoZoomTransition:: onEnter()
m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f)); m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f));
m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f)); m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f));
CCIntervalAction *rotozoom = static_cast<CCIntervalAction*>(CCSequence::actions CCIntervalAction *rotozoom = (CCIntervalAction*)(CCSequence::actions
( (
CCSpawn::actions CCSpawn::actions
( (
@ -280,8 +281,8 @@ void CCJumpZoomTransition::onEnter()
CCIntervalAction *scaleIn = CCScaleTo::actionWithDuration(m_fDuration/4, 1.0f); CCIntervalAction *scaleIn = CCScaleTo::actionWithDuration(m_fDuration/4, 1.0f);
CCIntervalAction *scaleOut = CCScaleTo::actionWithDuration(m_fDuration/4, 0.5f); CCIntervalAction *scaleOut = CCScaleTo::actionWithDuration(m_fDuration/4, 0.5f);
CCIntervalAction *jumpZoomOut = dynamic_cast<CCIntervalAction*>(CCSequence::actions(scaleOut, jump, NULL)); CCIntervalAction *jumpZoomOut = (CCIntervalAction*)(CCSequence::actions(scaleOut, jump, NULL));
CCIntervalAction *jumpZoomIn = dynamic_cast<CCIntervalAction*>(CCSequence::actions(jump, scaleIn, NULL)); CCIntervalAction *jumpZoomIn = (CCIntervalAction*)(CCSequence::actions(jump, scaleIn, NULL));
CCIntervalAction *delay = CCDelayTime::actionWithDuration(m_fDuration/2); CCIntervalAction *delay = CCDelayTime::actionWithDuration(m_fDuration/2);

View File

@ -118,7 +118,8 @@ namespace cocos2d{
CCNode * CCMenu::addChild(CCNode * child, int zOrder, int tag) CCNode * CCMenu::addChild(CCNode * child, int zOrder, int tag)
{ {
NSAssert( dynamic_cast<CCMenuItem*>(child) != NULL, L"Menu only supports MenuItem objects as children"); // we can not use RTTI, so we do not known the type of object
/*NSAssert( dynamic_cast<CCMenuItem*>(child) != NULL, L"Menu only supports MenuItem objects as children");*/
return __super::addChild(child, zOrder, tag); return __super::addChild(child, zOrder, tag);
} }
@ -513,8 +514,12 @@ namespace cocos2d{
{ {
break; break;
} }
dynamic_cast<CCRGBAProtocol*>(*it)->setOpacity(m_cOpacity); CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setOpacity(m_cOpacity);
}
} }
} }
} }
@ -538,7 +543,11 @@ namespace cocos2d{
break; break;
} }
dynamic_cast<CCRGBAProtocol*>(*it)->setColor(m_tColor); CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
if (pRGBAProtocol)
{
pRGBAProtocol->setColor(m_tColor);
}
} }
} }
} }

View File

@ -140,7 +140,7 @@ namespace cocos2d{
} }
void CCMenuItemLabel::setString(const char * label) void CCMenuItemLabel::setString(const char * label)
{ {
dynamic_cast<CCLabelProtocol*>(m_pLabel)->setString(label); m_pLabel->convertToLabelProtocol()->setString(label);
this->setContentSize(m_pLabel->getContentSize()); this->setContentSize(m_pLabel->getContentSize());
// [label_ setString:string]; // [label_ setString:string];
// [self setContentSize: [label_ contentSize]]; // [self setContentSize: [label_ contentSize]];
@ -185,12 +185,12 @@ namespace cocos2d{
{ {
if(enabled == false) if(enabled == false)
{ {
m_tColorBackup = dynamic_cast<CCRGBAProtocol*>(m_pLabel)->getColor(); m_tColorBackup = m_pLabel->convertToRGBAProtocol()->getColor();
dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setColor(m_tDisabledColor); m_pLabel->convertToRGBAProtocol()->setColor(m_tDisabledColor);
} }
else else
{ {
dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setColor(m_tColorBackup); m_pLabel->convertToRGBAProtocol()->setColor(m_tColorBackup);
} }
} }
__super::setIsEnabled(enabled); __super::setIsEnabled(enabled);
@ -201,19 +201,19 @@ namespace cocos2d{
} }
void CCMenuItemLabel::setOpacity(GLubyte opacity) void CCMenuItemLabel::setOpacity(GLubyte opacity)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setOpacity(opacity); m_pLabel->convertToRGBAProtocol()->setOpacity(opacity);
} }
GLubyte CCMenuItemLabel::getOpacity() GLubyte CCMenuItemLabel::getOpacity()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pLabel)->getOpacity(); return m_pLabel->convertToRGBAProtocol()->getOpacity();
} }
void CCMenuItemLabel::setColor(ccColor3B color) void CCMenuItemLabel::setColor(ccColor3B color)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setColor(color); m_pLabel->convertToRGBAProtocol()->setColor(color);
} }
ccColor3B CCMenuItemLabel::getColor() ccColor3B CCMenuItemLabel::getColor()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pLabel)->getColor(); return m_pLabel->convertToRGBAProtocol()->getColor();
} }
// //
@ -379,29 +379,31 @@ namespace cocos2d{
// //
void CCMenuItemImage::setOpacity(GLubyte opacity) void CCMenuItemImage::setOpacity(GLubyte opacity)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->setOpacity(opacity); m_pNormalImage->convertToRGBAProtocol()->setOpacity(opacity);
dynamic_cast<CCRGBAProtocol*>(m_pSelectedImage)->setOpacity(opacity); m_pSelectedImage->convertToRGBAProtocol()->setOpacity(opacity);
if (m_pDisabledImage) if (m_pDisabledImage)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pDisabledImage)->setOpacity(opacity); m_pDisabledImage->convertToRGBAProtocol()->setOpacity(opacity);
} }
} }
void CCMenuItemImage::setColor(ccColor3B color) void CCMenuItemImage::setColor(ccColor3B color)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->setColor(color); m_pNormalImage->convertToRGBAProtocol()->setColor(color);
dynamic_cast<CCRGBAProtocol*>(m_pSelectedImage)->setColor(color); m_pSelectedImage->convertToRGBAProtocol()->setColor(color);
if (m_pDisabledImage) if (m_pDisabledImage)
{ {
dynamic_cast<CCRGBAProtocol*>(m_pDisabledImage)->setColor(color); m_pDisabledImage->convertToRGBAProtocol()->setColor(color);
} }
} }
GLubyte CCMenuItemImage::getOpacity() GLubyte CCMenuItemImage::getOpacity()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getOpacity(); return m_pNormalImage->convertToRGBAProtocol()->getOpacity();
} }
ccColor3B CCMenuItemImage::getColor() ccColor3B CCMenuItemImage::getColor()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getColor(); return m_pNormalImage->convertToRGBAProtocol()->getColor();
} }
CCMenuItemImage * CCMenuItemImage::itemFromNormalImage(const char *normalImage, const char *selectedImage) CCMenuItemImage * CCMenuItemImage::itemFromNormalImage(const char *normalImage, const char *selectedImage)
{ {
@ -545,7 +547,7 @@ namespace cocos2d{
NSMutableArray<CCMenuItem*>::NSMutableArrayIterator it; NSMutableArray<CCMenuItem*>::NSMutableArrayIterator it;
for( it = m_pSubItems->begin(); it != m_pSubItems->end(); ++it) for( it = m_pSubItems->begin(); it != m_pSubItems->end(); ++it)
{ {
dynamic_cast<CCRGBAProtocol*>(*it)->setOpacity(opacity); (*it)->convertToRGBAProtocol()->setOpacity(opacity);
} }
} }
} }
@ -561,7 +563,7 @@ namespace cocos2d{
NSMutableArray<CCMenuItem*>::NSMutableArrayIterator it; NSMutableArray<CCMenuItem*>::NSMutableArrayIterator it;
for( it = m_pSubItems->begin(); it != m_pSubItems->end(); ++it) for( it = m_pSubItems->begin(); it != m_pSubItems->end(); ++it)
{ {
dynamic_cast<CCRGBAProtocol*>(*it)->setColor(color); (*it)->convertToRGBAProtocol()->setColor(color);
} }
} }
} }

View File

@ -113,7 +113,7 @@ public:
}; };
void plist_startElement(void *ctx, const xmlChar *name, const xmlChar **atts) void plist_startElement(void *ctx, const xmlChar *name, const xmlChar **atts)
{ {
CCDictMaker *pMaker = static_cast<CCDictMaker*>(ctx); CCDictMaker *pMaker = (CCDictMaker*)(ctx);
std::string sName((char*)name); std::string sName((char*)name);
if( sName == "dict" ) if( sName == "dict" )
{ {
@ -155,21 +155,21 @@ void plist_startElement(void *ctx, const xmlChar *name, const xmlChar **atts)
} }
void plist_endElement(void *ctx, const xmlChar *name) void plist_endElement(void *ctx, const xmlChar *name)
{ {
CCDictMaker * pMaker = static_cast<CCDictMaker*>(ctx); CCDictMaker * pMaker = (CCDictMaker*)(ctx);
std::string sName((char*)name); std::string sName((char*)name);
if( sName == "dict" ) if( sName == "dict" )
{ {
pMaker->m_tDictStack.pop(); pMaker->m_tDictStack.pop();
if ( !pMaker->m_tDictStack.empty() ) if ( !pMaker->m_tDictStack.empty() )
{ {
pMaker->m_pCurDict = static_cast<std::map<std::string, void*>*>(pMaker->m_tDictStack.top()); pMaker->m_pCurDict = (std::map<std::string, void*>*)(pMaker->m_tDictStack.top());
} }
} }
pMaker->m_tState = SAX_NONE; pMaker->m_tState = SAX_NONE;
} }
void plist_characters(void *ctx, const xmlChar *ch, int len) void plist_characters(void *ctx, const xmlChar *ch, int len)
{ {
CCDictMaker * pMaker = static_cast<CCDictMaker*>(ctx); CCDictMaker * pMaker = (CCDictMaker*)(ctx);
if (pMaker->m_tState == SAX_NONE) if (pMaker->m_tState == SAX_NONE)
{ {
return; return;

View File

@ -604,8 +604,8 @@ CCNode* CCSprite::addChild(CCNode *pChild, int zOrder, int tag)
if (m_bUsesSpriteSheet) if (m_bUsesSpriteSheet)
{ {
unsigned int index = m_pobSpriteSheet->atlasIndexForChild(static_cast<CCSprite*>(pChild), zOrder); unsigned int index = m_pobSpriteSheet->atlasIndexForChild((CCSprite*)(pChild), zOrder);
m_pobSpriteSheet->insertChild(static_cast<CCSprite*>(pChild), index); m_pobSpriteSheet->insertChild((CCSprite*)(pChild), index);
} }
m_bHasChildren = true; m_bHasChildren = true;
@ -641,7 +641,7 @@ void CCSprite::removeChild(CCNode *pChild, bool bCleanup)
{ {
if (m_bUsesSpriteSheet) if (m_bUsesSpriteSheet)
{ {
m_pobSpriteSheet->removeSpriteFromAtlas(static_cast<CCSprite*>(pChild)); m_pobSpriteSheet->removeSpriteFromAtlas((CCSprite*)(pChild));
} }
__super::removeChild(pChild, bCleanup); __super::removeChild(pChild, bCleanup);
@ -656,7 +656,7 @@ void CCSprite::removeAllChildrenWithCleanup(bool bCleanup)
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter) for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter)
{ {
pChild = static_cast<CCSprite*>(*iter); pChild = (CCSprite*)(*iter);
m_pobSpriteSheet->removeSpriteFromAtlas(pChild); m_pobSpriteSheet->removeSpriteFromAtlas(pChild);
} }
} }
@ -681,7 +681,7 @@ void CCSprite::setDirtyRecursively(bool bValue)
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter) for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter)
{ {
pChild = static_cast<CCSprite*>(*iter); pChild = (CCSprite*)(*iter);
pChild->setDirtyRecursively(true); pChild->setDirtyRecursively(true);
} }
} }
@ -973,8 +973,9 @@ void CCSprite::setTexture(CCTexture2D *texture)
// CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet
assert(! m_bUsesSpriteSheet); assert(! m_bUsesSpriteSheet);
// // accept texture==nil as argument // we can not use RTTI, so we do not known the type of object
assert((! texture) || dynamic_cast<CCTexture2D*>(texture)); // accept texture==nil as argument
/*assert((! texture) || dynamic_cast<CCTexture2D*>(texture));*/
CCX_SAFE_RELEASE(m_pobTexture); CCX_SAFE_RELEASE(m_pobTexture);

View File

@ -78,14 +78,14 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(map<string, void*> *pobDi
map<string, string*> *pMetadataMap = NULL; map<string, string*> *pMetadataMap = NULL;
if (metadataIter != pobDictionary->end()) if (metadataIter != pobDictionary->end())
{ {
pMetadataMap = static_cast<map<string, string*>*>(metadataIter->second); pMetadataMap = (map<string, string*>*)(metadataIter->second);
} }
map<string, void*>::iterator framesIter = pobDictionary->find("frames"); map<string, void*>::iterator framesIter = pobDictionary->find("frames");
map<string ,void*> *pFramesMap = NULL; map<string ,void*> *pFramesMap = NULL;
if (framesIter != pobDictionary->end()) if (framesIter != pobDictionary->end())
{ {
pFramesMap = static_cast<map<string, void*>*>(framesIter->second); pFramesMap = (map<string, void*>*)(framesIter->second);
} }
int format = 0; int format = 0;
@ -122,7 +122,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(map<string, void*> *pobDi
} }
CCSpriteFrame *pSpriteFrame; CCSpriteFrame *pSpriteFrame;
pFrame = static_cast<map<string, string*>*>(frameIter->second); pFrame = (map<string, string*>*)(frameIter->second);
if (format == 0) if (format == 0)
{ {
/* /*

View File

@ -166,7 +166,7 @@ CCNode* CCSpriteSheet::addChild(CCNode *child, int zOrder, int tag)
{ {
assert(child != NULL); assert(child != NULL);
CCSprite *pSprite = static_cast<CCSprite*>(child); CCSprite *pSprite = (CCSprite*)(child);
// check CCSprite is using the same texture id // check CCSprite is using the same texture id
assert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName()); assert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName());
@ -199,7 +199,7 @@ void CCSpriteSheet::reorderChild(CCNode *child, int zOrder)
// override remove child // override remove child
void CCSpriteSheet::removeChild(CCNode *child, bool cleanup) void CCSpriteSheet::removeChild(CCNode *child, bool cleanup)
{ {
CCSprite *pSprite = static_cast<CCSprite*>(child); CCSprite *pSprite = (CCSprite*)(child);
// explicit null handling // explicit null handling
if (pSprite == NULL) if (pSprite == NULL)
@ -217,7 +217,7 @@ void CCSpriteSheet::removeChild(CCNode *child, bool cleanup)
void CCSpriteSheet::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup) void CCSpriteSheet::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup)
{ {
removeChild(static_cast<CCSprite*>(m_pChildren->getObjectAtIndex(uIndex)), bDoCleanup); removeChild((CCSprite*)(m_pChildren->getObjectAtIndex(uIndex)), bDoCleanup);
} }
void CCSpriteSheet::removeAllChildrenWithCleanup(bool bCleanup) void CCSpriteSheet::removeAllChildrenWithCleanup(bool bCleanup)
@ -229,7 +229,7 @@ void CCSpriteSheet::removeAllChildrenWithCleanup(bool bCleanup)
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter) for (iter = m_pChildren->begin(); iter != m_pChildren->end(); ++iter)
{ {
pSprite = static_cast<CCSprite*>(*iter); pSprite = (CCSprite*)(*iter);
if (! pSprite) if (! pSprite)
{ {
@ -331,7 +331,7 @@ unsigned int CCSpriteSheet::rebuildIndexInOrder(CCSprite *pobParent, unsigned in
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = pChildren->begin(); iter != pChildren->end(); ++iter) for (iter = pChildren->begin(); iter != pChildren->end(); ++iter)
{ {
pSprite = static_cast<CCSprite*>(*iter); pSprite = (CCSprite*)(*iter);
if (! pSprite) if (! pSprite)
{ {
@ -358,7 +358,7 @@ unsigned int CCSpriteSheet::rebuildIndexInOrder(CCSprite *pobParent, unsigned in
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = pChildren->begin(); iter != pChildren->end(); ++iter) for (iter = pChildren->begin(); iter != pChildren->end(); ++iter)
{ {
pSprite = static_cast<CCSprite*>(*iter); pSprite = (CCSprite*)(*iter);
if (! pSprite) if (! pSprite)
{ {
@ -385,7 +385,7 @@ unsigned int CCSpriteSheet::highestAtlasIndexInChild(CCSprite *pSprite)
} }
else else
{ {
return highestAtlasIndexInChild(static_cast<CCSprite*>(pChildren->getLastObject())); return highestAtlasIndexInChild((CCSprite*)(pChildren->getLastObject()));
} }
} }
@ -399,7 +399,7 @@ unsigned int CCSpriteSheet::lowestAtlasIndexInChild(CCSprite *pSprite)
} }
else else
{ {
return lowestAtlasIndexInChild(static_cast<CCSprite*>(pChildren->getObjectAtIndex(0))); return lowestAtlasIndexInChild((CCSprite*)(pChildren->getObjectAtIndex(0)));
} }
} }
@ -409,11 +409,11 @@ unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, int nZ)
unsigned int uChildIndex = pBrothers->getIndexOfObject(pobSprite); unsigned int uChildIndex = pBrothers->getIndexOfObject(pobSprite);
// ignore parent Z if parent is spriteSheet // ignore parent Z if parent is spriteSheet
bool bIgnoreParent = static_cast<CCSpriteSheet*>(pobSprite->getParent()) == this; bool bIgnoreParent = (CCSpriteSheet*)(pobSprite->getParent()) == this;
CCSprite *pPrevious = NULL; CCSprite *pPrevious = NULL;
if (uChildIndex > 0) if (uChildIndex > 0)
{ {
pPrevious = static_cast<CCSprite*>(pBrothers->getObjectAtIndex(uChildIndex - 1)); pPrevious = (CCSprite*)(pBrothers->getObjectAtIndex(uChildIndex - 1));
} }
// first child of the sprite sheet // first child of the sprite sheet
@ -432,7 +432,7 @@ unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, int nZ)
// first child of an CCSprite ? // first child of an CCSprite ?
if (uChildIndex == 0) if (uChildIndex == 0)
{ {
CCSprite *p = static_cast<CCSprite*>(pobSprite->getParent()); CCSprite *p = (CCSprite*)(pobSprite->getParent());
// less than parent and brothers // less than parent and brothers
if (nZ < 0) if (nZ < 0)
@ -453,7 +453,7 @@ unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, int nZ)
} }
// else (previous < 0 and sprite >= 0 ) // else (previous < 0 and sprite >= 0 )
CCSprite *p = static_cast<CCSprite*>(pobSprite->getParent()); CCSprite *p = (CCSprite*)(pobSprite->getParent());
return p->getAtlasIndex() + 1; return p->getAtlasIndex() + 1;
} }
@ -509,7 +509,7 @@ void CCSpriteSheet::insertChild(CCSprite *pobSprite, unsigned int uIndex)
CCSprite *pSprite; CCSprite *pSprite;
for (iterNode = pChildren->begin(); iterNode != pChildren->end(); ++iterNode) for (iterNode = pChildren->begin(); iterNode != pChildren->end(); ++iterNode)
{ {
pSprite = static_cast<CCSprite*>(*iterNode); pSprite = (CCSprite*)(*iterNode);
if (! pSprite) if (! pSprite)
{ {
@ -541,7 +541,7 @@ void CCSpriteSheet::removeSpriteFromAtlas(CCSprite *pobSprite)
for(; uIndex < count; ++uIndex) for(; uIndex < count; ++uIndex)
{ {
CCSprite* s = static_cast<CCSprite*>(m_pobDescendants->getObjectAtIndex(uIndex)); CCSprite* s = (CCSprite*)(m_pobDescendants->getObjectAtIndex(uIndex));
s->setAtlasIndex( s->getAtlasIndex() - 1 ); s->setAtlasIndex( s->getAtlasIndex() - 1 );
} }
} }
@ -555,7 +555,7 @@ void CCSpriteSheet::removeSpriteFromAtlas(CCSprite *pobSprite)
NSMutableArray<CCNode*>::NSMutableArrayIterator iter; NSMutableArray<CCNode*>::NSMutableArrayIterator iter;
for (iter = pChildren->begin(); iter != pChildren->end(); ++iter) for (iter = pChildren->begin(); iter != pChildren->end(); ++iter)
{ {
pSprite = static_cast<CCSprite*>(*iter); pSprite = (CCSprite*)(*iter);
if (! pSprite) if (! pSprite)
{ {

View File

@ -162,8 +162,8 @@ CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat
m_uPixelsWide = pixelsWide; m_uPixelsWide = pixelsWide;
m_uPixelsHigh = pixelsHigh; m_uPixelsHigh = pixelsHigh;
m_ePixelFormat = pixelFormat; m_ePixelFormat = pixelFormat;
m_fMaxS = contentSize.width / static_cast<float>(pixelsWide); m_fMaxS = contentSize.width / (float)(pixelsWide);
m_fMaxT = contentSize.height / static_cast<float>(pixelsHigh); m_fMaxT = contentSize.height / (float)(pixelsHigh);
m_bHasPremultipliedAlpha = false; m_bHasPremultipliedAlpha = false;
@ -251,7 +251,7 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, un
pixelFormat = kCCTexture2DPixelFormat_A8; pixelFormat = kCCTexture2DPixelFormat_A8;
} }
imageSize = CGSizeMake(static_cast<float>(image->width()), static_cast<float>(image->height())); imageSize = CGSizeMake((float)(image->width()), (float)(image->height()));
// Create the bitmap graphics context // Create the bitmap graphics context
@ -277,7 +277,7 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, un
// info = kCGImageAlphaOnly; // info = kCGImageAlphaOnly;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info); // context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
tempData = static_cast<void*>(image->getRGBA8888Data()); tempData = (void*)(image->getRGBA8888Data());
NSAssert(tempData != NULL, "NULL image data."); NSAssert(tempData != NULL, "NULL image data.");
if(image->width() == POTWide && image->height() == POTHigh) if(image->width() == POTWide && image->height() == POTHigh)
{ {
@ -465,7 +465,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCData(const void *data, int level, int bp
} }
glCompressedTexImage2D(GL_TEXTURE_2D, level, format, length, length, 0, size, data); glCompressedTexImage2D(GL_TEXTURE_2D, level, format, length, length, 0, size, data);
m_tContentSize = CGSizeMake(static_cast<float>(length), static_cast<float>(length)); m_tContentSize = CGSizeMake((float)(length), (float)(length));
m_uPixelsWide = length; m_uPixelsWide = length;
m_uPixelsHigh = length; m_uPixelsHigh = length;
m_fMaxS = 1.0f; m_fMaxS = 1.0f;
@ -495,7 +495,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
m_uPixelsWide = pvr->getWidth(); // width m_uPixelsWide = pvr->getWidth(); // width
m_uPixelsHigh = pvr->getHeight(); // height m_uPixelsHigh = pvr->getHeight(); // height
/// be careful : unsigned int to float /// be careful : unsigned int to float
m_tContentSize = CGSizeMake(static_cast<float>(m_uPixelsWide), static_cast<float>(m_uPixelsHigh)); m_tContentSize = CGSizeMake((float)(m_uPixelsWide), (float)(m_uPixelsHigh));
pvr->release(); pvr->release();

View File

@ -266,13 +266,13 @@ void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, unsigned int u
NSSetIterator setIter; NSSetIterator setIter;
for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter) for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter)
{ {
pTouch = static_cast<CCTouch *>(*setIter); pTouch = (CCTouch *)(*setIter);
CCTargetedTouchHandler *pHandler; CCTargetedTouchHandler *pHandler;
NSMutableArray<CCTouchHandler*>::NSMutableArrayIterator arrayIter; NSMutableArray<CCTouchHandler*>::NSMutableArrayIterator arrayIter;
for (arrayIter = m_pTargetedHandlers->begin(); arrayIter != m_pTargetedHandlers->end(); ++arrayIter) for (arrayIter = m_pTargetedHandlers->begin(); arrayIter != m_pTargetedHandlers->end(); ++arrayIter)
/*for (unsigned int i = 0; i < m_pTargetedHandlers->num; ++i)*/ /*for (unsigned int i = 0; i < m_pTargetedHandlers->num; ++i)*/
{ {
pHandler = static_cast<CCTargetedTouchHandler *>(*arrayIter); pHandler = (CCTargetedTouchHandler *)(*arrayIter);
if (! pHandler) if (! pHandler)
{ {
@ -331,7 +331,7 @@ void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, unsigned int u
CCStandardTouchHandler *pHandler; CCStandardTouchHandler *pHandler;
for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter) for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter)
{ {
pHandler = static_cast<CCStandardTouchHandler*>(*iter); pHandler = (CCStandardTouchHandler*)(*iter);
if (! pHandler) if (! pHandler)
{ {