From 6f99f7efde378e028a802030432280ea7a340b5a Mon Sep 17 00:00:00 2001 From: Leon Date: Sat, 26 Nov 2011 22:37:36 +0800 Subject: [PATCH 1/3] 1. fix multi touch index. 2. swap. 3. create gl view. --- cocos2dx/platform/ios/EAGLView.mm | 51 +++---- cocos2dx/support/CCPointExtension.cpp | 190 +++++++++++++------------- 2 files changed, 122 insertions(+), 119 deletions(-) diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index 3235c214a1..b9a9476732 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -146,12 +146,12 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES]; [self release]; return nil; } + touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL); + indexBitsUsed = 0x00000000; + + view = self; } - touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL); - indexBitsUsed = 0x00000000; - - view = self; return self; } @@ -398,30 +398,33 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES]; cocos2d::CCTouch *pTouch; for (UITouch *touch in touches) { - NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); - int unUsedIndex = 0; + NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); + int unUsedIndex = 0; - // it is a new touch - if (! index) { - unUsedIndex = [self getUnUsedIndex]; - - // The touches is more than MAX_TOUCHES ? - if (unUsedIndex == -1) { - return; - } - - pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch(); - } - - float x = [touch locationInView: [touch view]].x; - float y = [touch locationInView: [touch view]].y; - pTouch->SetTouchInfo(0, x, y); + // it is a new touch + if (! index) { + unUsedIndex = [self getUnUsedIndex]; + + // The touches is more than MAX_TOUCHES ? + if (unUsedIndex == -1) { + return; + } + + pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch(); + float x = [touch locationInView: [touch view]].x; + float y = [touch locationInView: [touch view]].y; + pTouch->SetTouchInfo(0, x, y); + + CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:unUsedIndex]); + + set.addObject(pTouch); + } - CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:unUsedIndex]); - - set.addObject(pTouch); } + if (set.count() == 0) + return; + cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesBegan(&set); } diff --git a/cocos2dx/support/CCPointExtension.cpp b/cocos2dx/support/CCPointExtension.cpp index d51961af79..ebd991301e 100644 --- a/cocos2dx/support/CCPointExtension.cpp +++ b/cocos2dx/support/CCPointExtension.cpp @@ -1,34 +1,34 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +/**************************************************************************** +Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2007 Scott Lembcke -Copyright (c) 2010 Lam Pham - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "CCPointExtension.h" -#include "ccMacros.h" // FLT_EPSILON -#include -namespace cocos2d { - +Copyright (c) 2010 Lam Pham + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "CCPointExtension.h" +#include "ccMacros.h" // FLT_EPSILON +#include +namespace cocos2d { + #define kCCPointEpsilon FLT_EPSILON CGFloat @@ -72,7 +72,7 @@ float clampf(float value, float min_inclusive, float max_inclusive) float ftmp; ftmp = min_inclusive; min_inclusive = max_inclusive; - max_inclusive = min_inclusive; + max_inclusive = ftmp; } return value < min_inclusive ? min_inclusive : value < max_inclusive? value : max_inclusive; } @@ -119,79 +119,79 @@ CCPoint ccpRotateByAngle(const CCPoint& v, const CCPoint& pivot, float angle) CCPoint r = ccpSub(v, pivot); float cosa = cosf(angle), sina = sinf(angle); float t = r.x; - r.x = t*cosa - r.y*sina + pivot.x; + r.x = t*cosa - r.y*sina + pivot.x; r.y = t*sina + r.y*cosa + pivot.y; return r; } - -bool ccpSegmentIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) -{ - float S, T; - - if( ccpLineIntersect(A, B, C, D, &S, &T ) - && (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f) ) - return true; - - return false; -} - -CCPoint ccpIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) -{ - float S, T; - - if( ccpLineIntersect(A, B, C, D, &S, &T) ) - { - // Point of intersection - CCPoint P; - P.x = A.x + S * (B.x - A.x); - P.y = A.y + S * (B.y - A.y); - return P; - } - - return CCPointZero; + +bool ccpSegmentIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) +{ + float S, T; + + if( ccpLineIntersect(A, B, C, D, &S, &T ) + && (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f) ) + return true; + + return false; +} + +CCPoint ccpIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) +{ + float S, T; + + if( ccpLineIntersect(A, B, C, D, &S, &T) ) + { + // Point of intersection + CCPoint P; + P.x = A.x + S * (B.x - A.x); + P.y = A.y + S * (B.y - A.y); + return P; + } + + return CCPointZero; } bool ccpLineIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D, float *S, float *T) { - // FAIL: Line undefined - if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) - { - return false; - } - const float BAx = B.x - A.x; - const float BAy = B.y - A.y; - const float DCx = D.x - C.x; - const float DCy = D.y - C.y; - const float ACx = A.x - C.x; - const float ACy = A.y - C.y; - - const float denom = DCy*BAx - DCx*BAy; - - *S = DCx*ACy - DCy*ACx; - *T = BAx*ACy - BAy*ACx; - - if (denom == 0) - { - if (*S == 0 || *T == 0) - { - // Lines incident - return true; - } - // Lines parallel and not incident - return false; - } - - *S = *S / denom; - *T = *T / denom; - - // Point of intersection - // CGPoint P; - // P.x = A.x + *S * (B.x - A.x); - // P.y = A.y + *S * (B.y - A.y); - + // FAIL: Line undefined + if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) + { + return false; + } + const float BAx = B.x - A.x; + const float BAy = B.y - A.y; + const float DCx = D.x - C.x; + const float DCy = D.y - C.y; + const float ACx = A.x - C.x; + const float ACy = A.y - C.y; + + const float denom = DCy*BAx - DCx*BAy; + + *S = DCx*ACy - DCy*ACx; + *T = BAx*ACy - BAy*ACx; + + if (denom == 0) + { + if (*S == 0 || *T == 0) + { + // Lines incident + return true; + } + // Lines parallel and not incident + return false; + } + + *S = *S / denom; + *T = *T / denom; + + // Point of intersection + // CGPoint P; + // P.x = A.x + *S * (B.x - A.x); + // P.y = A.y + *S * (B.y - A.y); + return true; } @@ -201,4 +201,4 @@ float ccpAngle(const CCPoint& a, const CCPoint& b) if( fabs(angle) < kCCPointEpsilon ) return 0.f; return angle; } -}//namespace cocos2d +}//namespace cocos2d From f0d22ae504cb164e7f50fd1078fdd238da0918ec Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 28 Nov 2011 17:28:43 +0800 Subject: [PATCH 2/3] issue #879: replase assert with CCAssert --- cocos2dx/CCCamera.cpp | 1 + cocos2dx/CCDirector.cpp | 14 +++--- cocos2dx/CCDrawingPrimitives.cpp | 2 +- cocos2dx/CCScheduler.cpp | 30 ++++++------- cocos2dx/actions/CCAction.cpp | 6 +-- cocos2dx/actions/CCActionEase.cpp | 4 +- cocos2dx/actions/CCActionGrid.cpp | 4 +- cocos2dx/actions/CCActionGrid3D.cpp | 3 +- cocos2dx/actions/CCActionInterval.cpp | 26 +++++------ cocos2dx/actions/CCActionManager.cpp | 14 +++--- cocos2dx/base_nodes/CCAtlasNode.cpp | 3 +- cocos2dx/base_nodes/CCNode.cpp | 2 +- cocos2dx/cocoa/CCAutoreleasePool.cpp | 9 ++-- cocos2dx/cocoa/CCObject.cpp | 10 ++--- cocos2dx/effects/CCGrid.cpp | 6 +-- cocos2dx/include/CCLayer.h | 1 + cocos2dx/include/CCMenuItem.h | 1 + cocos2dx/include/CCMutableArray.h | 6 +-- cocos2dx/include/CCRibbon.h | 1 + cocos2dx/include/ccMacros.h | 1 - cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 4 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 5 ++- .../CCLayer.cpp | 2 +- cocos2dx/menu_nodes/CCMenu.cpp | 12 ++--- cocos2dx/menu_nodes/CCMenuItem.cpp | 2 +- cocos2dx/misc_nodes/CCProgressTimer.cpp | 4 +- cocos2dx/misc_nodes/CCRibbon.cpp | 1 + cocos2dx/particle_nodes/CCParticleSystem.cpp | 3 +- .../particle_nodes/CCParticleSystemQuad.cpp | 1 + cocos2dx/platform/CCFileUtils.cpp | 1 + cocos2dx/platform/win32/CCFileUtils_win32.cpp | 1 + cocos2dx/sprite_nodes/CCSprite.cpp | 44 +++++++++---------- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 14 +++--- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 1 + cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 4 +- cocos2dx/support/data_support/ccCArray.h | 2 +- cocos2dx/support/zip_support/ZipUtils.cpp | 8 ++-- cocos2dx/textures/CCTexture2D.cpp | 3 +- cocos2dx/textures/CCTextureAtlas.cpp | 4 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 1 + .../tileMap_parallax_nodes/CCTMXTiledMap.cpp | 2 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 2 +- .../touch_dispatcher/CCTouchDispatcher.cpp | 9 ++-- cocos2dx/touch_dispatcher/CCTouchHandler.cpp | 2 +- 45 files changed, 146 insertions(+), 132 deletions(-) diff --git a/cocos2dx/CCCamera.cpp b/cocos2dx/CCCamera.cpp index 292f8c7ef8..c400b1b4b0 100644 --- a/cocos2dx/CCCamera.cpp +++ b/cocos2dx/CCCamera.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "CCGL.h" #include "CCDrawingPrimitives.h" +#include "CCDirector.h" using namespace std; namespace cocos2d { diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index cd1566716d..6aa7001706 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -156,7 +156,7 @@ CCDirector::~CCDirector(void) void CCDirector::setGLDefaultValues(void) { // This method SHOULD be called only after openGLView_ was initialized - assert(m_pobOpenGLView); + CCAssert(m_pobOpenGLView, "opengl view should not be null"); setAlphaBlending(true); setDepthTest(true); @@ -275,7 +275,7 @@ void CCDirector::calculateDeltaTime(void) void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView) { - assert(pobOpenGLView); + CCAssert(pobOpenGLView, "opengl view should not be null"); if (m_pobOpenGLView != pobOpenGLView) { @@ -494,8 +494,8 @@ void CCDirector::reshapeProjection(const CCSize& newWindowSize) void CCDirector::runWithScene(CCScene *pScene) { - assert(pScene != NULL); - assert(m_pRunningScene == NULL); + CCAssert(pScene != NULL, "running scene should not be null"); + CCAssert(m_pRunningScene == NULL, "m_pRunningScene should be null"); pushScene(pScene); startAnimation(); @@ -503,7 +503,7 @@ void CCDirector::runWithScene(CCScene *pScene) void CCDirector::replaceScene(CCScene *pScene) { - assert(pScene != NULL); + CCAssert(pScene != NULL, "the scene should not be null"); unsigned int index = m_pobScenesStack->count(); @@ -515,7 +515,7 @@ void CCDirector::replaceScene(CCScene *pScene) void CCDirector::pushScene(CCScene *pScene) { - assert(pScene); + CCAssert(pScene, "the scene should not null"); m_bSendCleanupToScene = false; @@ -525,7 +525,7 @@ void CCDirector::pushScene(CCScene *pScene) void CCDirector::popScene(void) { - assert(m_pRunningScene != NULL); + CCAssert(m_pRunningScene != NULL, "running scene should not null"); m_pobScenesStack->removeLastObject(); unsigned int c = m_pobScenesStack->count(); diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 20a2571efd..91bb5e61d5 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -28,10 +28,10 @@ THE SOFTWARE. #include "ccTypes.h" #include "ccMacros.h" #include "CCGL.h" +#include "CCDirector.h" #include #include -#include "CCGL.h" #ifndef M_PI #define M_PI 3.14159265358979323846 diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index bee15e2f10..eb879549e8 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -31,8 +31,6 @@ THE SOFTWARE. #include "CCMutableArray.h" #include "CCScriptSupport.h" -#include - using namespace std; namespace cocos2d { @@ -189,7 +187,7 @@ CCScheduler::CCScheduler(void) , m_bCurrentTargetSalvaged(false) , m_pHashForScriptFunctions(NULL) { - assert(pSharedScheduler == NULL); + CCAssert(pSharedScheduler == NULL, ""); } CCScheduler::~CCScheduler(void) @@ -245,8 +243,8 @@ void CCScheduler::removeHashElement(_hashSelectorEntry *pElement) void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget, float fInterval, bool bPaused) { - assert(pfnSelector); - assert(pTarget); + CCAssert(pfnSelector, ""); + CCAssert(pTarget, ""); tHashSelectorEntry *pElement = NULL; HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); @@ -266,7 +264,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *p } else { - assert(pElement->paused == bPaused); + CCAssert(pElement->paused == bPaused, ""); } if (pElement->timers == NULL) @@ -297,8 +295,8 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *p void CCScheduler::scheduleScriptFunc(const char *pszFuncName, ccTime fInterval, bool bPaused) { - //assert(pfnSelector); - assert(pszFuncName); + //CCAssert(pfnSelector); + CCAssert(pszFuncName, ""); tHashScriptFuncEntry *pElement = NULL; HASH_FIND_INT(m_pHashForScriptFunctions, &pszFuncName, pElement); @@ -315,7 +313,7 @@ void CCScheduler::scheduleScriptFunc(const char *pszFuncName, ccTime fInterval, } else { - assert(pElement->paused == bPaused); + CCAssert(pElement->paused == bPaused, ""); } } @@ -327,8 +325,8 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol return; } - //assert(pTarget); - //assert(pfnSelector); + //CCAssert(pTarget); + //CCAssert(pfnSelector); tHashSelectorEntry *pElement = NULL; HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); @@ -477,7 +475,7 @@ void CCScheduler::scheduleUpdateForTarget(SelectorProtocol *pTarget, int nPriori if (pHashElement) { #if COCOS2D_DEBUG >= 1 - assert(pHashElement->entry->markedForDeletion); + CCAssert(pHashElement->entry->markedForDeletion); #endif // TODO: check if priority has changed! @@ -620,7 +618,7 @@ void CCScheduler::unscheduleAllSelectorsForTarget(SelectorProtocol *pTarget) void CCScheduler::resumeTarget(SelectorProtocol *pTarget) { - assert(pTarget != NULL); + CCAssert(pTarget != NULL, ""); // custom selectors tHashSelectorEntry *pElement = NULL; @@ -635,14 +633,14 @@ void CCScheduler::resumeTarget(SelectorProtocol *pTarget) HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate); if (pElementUpdate) { - assert(pElementUpdate->entry != NULL); + CCAssert(pElementUpdate->entry != NULL, ""); pElementUpdate->entry->paused = false; } } void CCScheduler::pauseTarget(SelectorProtocol *pTarget) { - assert(pTarget != NULL); + CCAssert(pTarget != NULL, ""); // custom selectors tHashSelectorEntry *pElement = NULL; @@ -657,7 +655,7 @@ void CCScheduler::pauseTarget(SelectorProtocol *pTarget) HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate); if (pElementUpdate) { - assert(pElementUpdate->entry != NULL); + CCAssert(pElementUpdate->entry != NULL, ""); pElementUpdate->entry->paused = true; } } diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index c749730cc1..2fc53ce441 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -137,7 +137,7 @@ CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fRate) bool CCSpeed::initWithAction(CCActionInterval *pAction, float fRate) { - assert(pAction != NULL); + CCAssert(pAction != NULL, ""); pAction->retain(); m_pInnerAction = pAction; m_fSpeed = fRate; @@ -235,7 +235,7 @@ CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect) bool CCFollow::initWithTarget(CCNode *pFollowedNode) { - assert(pFollowedNode != NULL); + CCAssert(pFollowedNode != NULL, ""); pFollowedNode->retain(); m_pobFollowedNode = pFollowedNode; m_bBoundarySet = false; @@ -249,7 +249,7 @@ bool CCFollow::initWithTarget(CCNode *pFollowedNode) bool CCFollow::initWithTarget(CCNode *pFollowedNode, const CCRect& rect) { - assert(pFollowedNode != NULL); + CCAssert(pFollowedNode != NULL, ""); pFollowedNode->retain(); m_pobFollowedNode = pFollowedNode; m_bBoundarySet = true; diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index e84fb9aa0c..c03bf33ad0 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -62,7 +62,7 @@ namespace cocos2d { bool CCActionEase::initWithAction(CCActionInterval *pAction) { - assert(pAction != NULL); + CCAssert(pAction != NULL, ""); if (CCActionInterval::initWithDuration(pAction->getDuration())) { @@ -740,7 +740,7 @@ namespace cocos2d { CCActionInterval* CCEaseElastic::reverse(void) { - assert(0); + CCAssert(0, ""); return NULL; } diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 3937fe7eca..7bc74e414d 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -78,7 +78,7 @@ namespace cocos2d } else { - assert(0); + CCAssert(0, ""); } } else @@ -96,7 +96,7 @@ namespace cocos2d CCGridBase* CCGridAction::getGrid(void) { // Abstract class needs implementation - assert(0); + CCAssert(0, ""); return NULL; } diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 2185e4784f..60c74f3e3c 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCActionGrid3D.h" #include "CCPointExtension.h" +#include "CCDirector.h" #include @@ -134,7 +135,7 @@ namespace cocos2d if (gridSize.x != 1 || gridSize.y != 1) { // Grid size must be (1,1) - assert(0); + CCAssert(0, ""); return false; } diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index ac510612b4..5e754c1cd3 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -76,7 +76,7 @@ CCObject* CCActionInterval::copyWithZone(CCZone *pZone) else { // action's base class , must be called using __super::copyWithZone(), after overriding from derived class - assert(0); + CCAssert(0, ""); pCopy = new CCActionInterval(); pZone = pNewZone = new CCZone(pCopy); @@ -117,13 +117,13 @@ void CCActionInterval::setAmplitudeRate(CGFloat amp) { CC_UNUSED_PARAM(amp); // Abstract class needs implementation - assert(0); + CCAssert(0, ""); } CGFloat CCActionInterval::getAmplitudeRate(void) { // Abstract class needs implementation - assert(0); + CCAssert(0, ""); return 0; } @@ -198,8 +198,8 @@ CCFiniteTimeAction* CCSequence::actionsWithArray(CCArray *actions) bool CCSequence::initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) { - assert(pActionOne != NULL); - assert(pActionTwo != NULL); + CCAssert(pActionOne != NULL, ""); + CCAssert(pActionTwo != NULL, ""); ccTime d = pActionOne->getDuration() + pActionTwo->getDuration(); CCActionInterval::initWithDuration(d); @@ -459,7 +459,7 @@ CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) bool CCRepeatForever::initWithAction(CCActionInterval *pAction) { - assert(pAction != NULL); + CCAssert(pAction != NULL, ""); pAction->retain(); m_pInnerAction = pAction; return true; @@ -563,8 +563,8 @@ CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) { - assert(pAction1 != NULL); - assert(pAction2 != NULL); + CCAssert(pAction1 != NULL, ""); + CCAssert(pAction2 != NULL, ""); bool bRet = false; @@ -1941,8 +1941,8 @@ CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction) bool CCReverseTime::initWithAction(CCFiniteTimeAction *pAction) { - assert(pAction != NULL); - assert(pAction != m_pOther); + CCAssert(pAction != NULL, ""); + CCAssert(pAction != m_pOther, ""); if (CCActionInterval::initWithDuration(pAction->getDuration())) { @@ -2030,7 +2030,7 @@ CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation) bool CCAnimate::initWithAnimation(CCAnimation *pAnimation) { - assert(pAnimation != NULL); + CCAssert(pAnimation != NULL, ""); return initWithAnimation(pAnimation, true); } @@ -2046,7 +2046,7 @@ CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation, bool bRestore bool CCAnimate::initWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame) { - assert(pAnimation); + CCAssert(pAnimation, ""); if (CCActionInterval::initWithDuration(pAnimation->getFrames()->count() * pAnimation->getDelay())) { @@ -2072,7 +2072,7 @@ CCAnimate* CCAnimate::actionWithDuration(ccTime duration, CCAnimation *pAnimatio bool CCAnimate::initWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame) { - assert(pAnimation != NULL); + CCAssert(pAnimation != NULL, ""); if (CCActionInterval::initWithDuration(duration)) { diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index fa990dc0b1..7733a74ebc 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -89,7 +89,7 @@ CCActionManager::CCActionManager(void) m_pCurrentTarget(NULL), m_bCurrentTargetSalvaged(false) { - assert(gSharedManager == NULL); + CCAssert(gSharedManager == NULL, ""); } CCActionManager::~CCActionManager(void) @@ -191,8 +191,8 @@ void CCActionManager::resumeTarget(CCObject *pTarget) void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused) { - assert(pAction != NULL); - assert(pTarget != NULL); + CCAssert(pAction != NULL, ""); + CCAssert(pTarget != NULL, ""); tHashElement *pElement = NULL; // we should convert it to CCObject*, because we save it as CCObject* @@ -209,7 +209,7 @@ void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused) actionAllocWithHashElement(pElement); - assert(! ccArrayContainsObject(pElement->actions, pAction)); + CCAssert(! ccArrayContainsObject(pElement->actions, pAction), ""); ccArrayAppendObject(pElement->actions, pAction); pAction->startWithTarget(pTarget); @@ -288,8 +288,8 @@ void CCActionManager::removeAction(CCAction *pAction) void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget) { - assert((int)tag != kCCActionTagInvalid); - assert(pTarget != NULL); + CCAssert((int)tag != kCCActionTagInvalid, ""); + CCAssert(pTarget != NULL, ""); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); @@ -314,7 +314,7 @@ void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget) CCAction* CCActionManager::getActionByTag(unsigned int tag, CCObject *pTarget) { - assert((int)tag != kCCActionTagInvalid); + CCAssert((int)tag != kCCActionTagInvalid, ""); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index e90847f759..b2cfd502a2 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "CCAtlasNode.h" #include "CCTextureAtlas.h" +#include "CCDirector.h" namespace cocos2d { @@ -66,7 +67,7 @@ CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tile bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender) { - assert(tile != NULL); + CCAssert(tile != NULL, "title should not be null"); m_uItemWidth = (int) (tileWidth * CC_CONTENT_SCALE_FACTOR()); m_uItemHeight = (int) (tileHeight * CC_CONTENT_SCALE_FACTOR()); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index b5419e512d..8598e2cbed 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -718,7 +718,7 @@ void CCNode::reorderChild(CCNode *child, int zOrder) void CCNode::draw() { - //assert(0); + //CCAssert(0); // override me // Only use- this function to draw your staff. // DON'T draw your stuff outside this method diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index 5974c3fab1..1b09d47d61 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAutoreleasePool.h" +#include "ccMacros.h" namespace cocos2d { @@ -42,7 +43,7 @@ void CCAutoreleasePool::addObject(CCObject* pObject) { m_pManagedObjectArray->addObject(pObject); - assert(pObject->m_uReference > 1); + CCAssert(pObject->m_uReference > 1, "reference count should greager than 1"); pObject->release(); // no ref count, in this case autorelease pool added. } @@ -162,7 +163,7 @@ void CCPoolManager::pop() void CCPoolManager::removeObject(CCObject* pObject) { - assert(m_pCurReleasePool); + CCAssert(m_pCurReleasePool, "current auto release pool should not be null"); m_pCurReleasePool->removeObject(pObject); } @@ -176,9 +177,11 @@ void CCPoolManager::addObject(CCObject* pObject) CCAutoreleasePool* CCPoolManager::getCurReleasePool() { if(!m_pCurReleasePool) + { push(); + } - assert(m_pCurReleasePool); + CCAssert(m_pCurReleasePool, "current auto release pool should not be null"); return m_pCurReleasePool; } diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index 2c62f01cf7..2664431ff9 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -25,14 +25,14 @@ THE SOFTWARE. #include "CCObject.h" #include "CCAutoreleasePool.h" -#include +#include "ccMacros.h" namespace cocos2d { CCObject* CCCopying::copyWithZone(CCZone *pZone) { CC_UNUSED_PARAM(pZone); - assert(0); - return 0; + CCAssert(0, "not implement"); + return 0; } @@ -64,7 +64,7 @@ CCObject* CCObject::copy() void CCObject::release(void) { - assert(m_uReference > 0); + CCAssert(m_uReference > 0, "reference count should greater than 0"); --m_uReference; if (m_uReference == 0) @@ -75,7 +75,7 @@ void CCObject::release(void) void CCObject::retain(void) { - assert(m_uReference > 0); + CCAssert(m_uReference > 0, "reference count should greater than 0"); ++m_uReference; } diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 99b09d8e1a..853268e1d1 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -274,17 +274,17 @@ namespace cocos2d void CCGridBase::blit(void) { - assert(0); + CCAssert(0, ""); } void CCGridBase::reuse(void) { - assert(0); + CCAssert(0, ""); } void CCGridBase::calculateVertexPoints(void) { - assert(0); + CCAssert(0, ""); } // implementation of CCGrid3D diff --git a/cocos2dx/include/CCLayer.h b/cocos2dx/include/CCLayer.h index 994e5209aa..1be89afbc4 100755 --- a/cocos2dx/include/CCLayer.h +++ b/cocos2dx/include/CCLayer.h @@ -32,6 +32,7 @@ THE SOFTWARE. #include "CCTouchDelegateProtocol.h" #include "CCAccelerometerDelegate.h" #include "CCKeypadDelegate.h" +#include "CCMutableArray.h" namespace cocos2d { diff --git a/cocos2dx/include/CCMenuItem.h b/cocos2dx/include/CCMenuItem.h index 45bdaa76cd..5842afabd5 100755 --- a/cocos2dx/include/CCMenuItem.h +++ b/cocos2dx/include/CCMenuItem.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include "CCNode.h" #include "CCProtocols.h" #include "selector_protocol.h" +#include "CCMutableArray.h" namespace cocos2d{ diff --git a/cocos2dx/include/CCMutableArray.h b/cocos2dx/include/CCMutableArray.h index d983645dee..abd84cd2a0 100755 --- a/cocos2dx/include/CCMutableArray.h +++ b/cocos2dx/include/CCMutableArray.h @@ -26,8 +26,8 @@ THE SOFTWARE. #define __COCOA_CC_MUTABLE_ARRAY_H__ #include "CCObject.h" +#include "ccMacros.h" #include -#include #include namespace cocos2d { @@ -113,7 +113,7 @@ public: T getObjectAtIndex(unsigned int uIndex) { - assert(uIndex < count()); + CCAssert(uIndex < count(), ""); if (uIndex >= count()) { @@ -155,7 +155,7 @@ public: void insertObjectAtIndex(T pObject, unsigned int uIndex) { - assert(uIndex <= count()); + CCAssert(uIndex <= count(), ""); // make sure the object is not null if (pObject == 0) { diff --git a/cocos2dx/include/CCRibbon.h b/cocos2dx/include/CCRibbon.h index 688266a3d8..d99fe22c01 100755 --- a/cocos2dx/include/CCRibbon.h +++ b/cocos2dx/include/CCRibbon.h @@ -28,6 +28,7 @@ THE SOFTWARE. /*#include */ #include "CCNode.h" #include "CCProtocols.h" +#include "CCMutableArray.h" namespace cocos2d { diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 46cb27ab4b..5fd45528e2 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -135,7 +135,6 @@ default gl blend src function. Compatible with premultiplied alpha images. On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1 */ -#include "CCDirector.h" #define CC_CONTENT_SCALE_FACTOR() CCDirector::sharedDirector()->getContentScaleFactor() diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index f5f57fdf4c..e710322294 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -46,7 +46,7 @@ namespace cocos2d{ bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) { - assert(label != NULL); + CCAssert(label != NULL, ""); if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label))) { m_cMapStartChar = startCharMap; diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 16acc24455..5775b27931 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -102,7 +102,7 @@ namespace cocos2d{ } bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile) { - assert(FNTfile != NULL && strlen(FNTfile)!=0); + CCAssert(FNTfile != NULL && strlen(FNTfile)!=0, ""); m_pKerningDictionary = NULL; this->parseConfigFile(FNTfile); return true; @@ -395,7 +395,7 @@ namespace cocos2d{ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) { - assert(theString != NULL); + CCAssert(theString != NULL, ""); CC_SAFE_RELEASE(m_pConfiguration);// allow re-init m_pConfiguration = FNTConfigLoadFile(fntFile); m_pConfiguration->retain(); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index f491f8b931..295d74b373 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLabelTTF.h" +#include "CCDirector.h" namespace cocos2d{ // @@ -67,7 +68,7 @@ namespace cocos2d{ bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) { - assert(label != NULL); + CCAssert(label != NULL, ""); if (CCSprite::init()) { m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() ); @@ -88,7 +89,7 @@ namespace cocos2d{ } bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize) { - assert(label != NULL); + CCAssert(label != NULL, ""); if (CCSprite::init()) { m_tDimensions = CCSizeZero; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 537cad5059..3f0398d369 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -665,7 +665,7 @@ CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) } void CCLayerMultiplex::addLayer(CCLayer* layer) { - assert(m_pLayers); + CCAssert(m_pLayers, ""); m_pLayers->addObject(layer); } diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 00c3d7de7c..05a82a28b8 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -357,11 +357,11 @@ namespace cocos2d{ CCNode* pChild = (CCNode*) pObject; if (pChild) { - assert(row < rows.size()); + CCAssert(row < rows.size(), ""); rowColumns = rows[row]; // can not have zero columns on a row - assert(rowColumns); + CCAssert(rowColumns, ""); float tmp = pChild->getContentSize().height; rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); @@ -380,7 +380,7 @@ namespace cocos2d{ } // check if too many rows/columns for available menu items - assert(! columnsOccupied); + CCAssert(! columnsOccupied, ""); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); @@ -467,11 +467,11 @@ namespace cocos2d{ if (pChild) { // check if too many menu items for the amount of rows/columns - assert(column < columns.size()); + CCAssert(column < columns.size(), ""); columnRows = columns[column]; // can't have zero rows on a column - assert(columnRows); + CCAssert(columnRows, ""); // columnWidth = fmaxf(columnWidth, [item contentSize].width); float tmp = pChild->getContentSize().width; @@ -496,7 +496,7 @@ namespace cocos2d{ } // check if too many rows/columns for available menu items. - assert(! rowsOccupied); + CCAssert(! rowsOccupied, ""); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 640e8e2f5b..77c032688a 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -498,7 +498,7 @@ namespace cocos2d{ } bool CCMenuItemSprite::initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector) { - assert(normalSprite != NULL); + CCAssert(normalSprite != NULL, ""); CCMenuItem::initWithTarget(target, selector); setNormalImage(normalSprite); setSelectedImage(selectedSprite); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 6ed0fc79dc..dae66441af 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -343,7 +343,7 @@ void CCProgressTimer::updateRadial(void) { m_nVertexDataCount = index + 3; m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount]; - assert(m_pVertexData); + CCAssert(m_pVertexData, ""); updateColor(); } @@ -432,7 +432,7 @@ void CCProgressTimer::updateBar(void) { m_nVertexDataCount = kProgressTextureCoordsCount; m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount]; - assert(m_pVertexData); + CCAssert(m_pVertexData, ""); if (m_eType == kCCProgressTimerTypeHorizontalBarLR) { diff --git a/cocos2dx/misc_nodes/CCRibbon.cpp b/cocos2dx/misc_nodes/CCRibbon.cpp index e052330882..4a48adeb0e 100644 --- a/cocos2dx/misc_nodes/CCRibbon.cpp +++ b/cocos2dx/misc_nodes/CCRibbon.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "CCRibbon.h" #include "CCTextureCache.h" #include "CCPointExtension.h" +#include "CCDirector.h" namespace cocos2d { diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index bccbc0bf7b..038499c3c3 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -50,6 +50,7 @@ THE SOFTWARE. #include "CCImage.h" #include "platform/platform.h" #include "support/zip_support/ZipUtils.h" +#include "CCDirector.h" // opengl #include "platform/CCGL.h" @@ -291,7 +292,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary * else { char *textureData = (char*)valueForKey("textureImageData", dictionary); - assert(textureData); + CCAssert(textureData, ""); int dataLen = strlen(textureData); if(dataLen != 0) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index b56faa575a..66d0a5caaa 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -29,6 +29,7 @@ THE SOFTWARE. #include "CCParticleSystemQuad.h" #include "CCSpriteFrame.h" +#include "CCDirector.h" namespace cocos2d { diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 8307bad1de..4e168a5506 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCFileUtils.h" +#include "CCDirector.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY) diff --git a/cocos2dx/platform/win32/CCFileUtils_win32.cpp b/cocos2dx/platform/win32/CCFileUtils_win32.cpp index 98dc525594..dc11d0e0ff 100644 --- a/cocos2dx/platform/win32/CCFileUtils_win32.cpp +++ b/cocos2dx/platform/win32/CCFileUtils_win32.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "windows.h" +#include "CCDirector.h" using namespace std; diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 2dcd4c259a..5f616806d6 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "CCGeometry.h" #include "CCTexture2D.h" #include "CCAffineTransform.h" +#include "CCDirector.h" #include @@ -123,7 +124,7 @@ CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect, CC_UNUSED_PARAM(rect); CC_UNUSED_PARAM(offset); // not implement - assert(0); + CCAssert(0, ""); return NULL; } @@ -224,7 +225,7 @@ bool CCSprite::init(void) bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect) { - assert(pTexture != NULL); + CCAssert(pTexture != NULL, ""); // IMPORTANT: [self init] and not [super init]; init(); setTexture(pTexture); @@ -235,7 +236,7 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect) bool CCSprite::initWithTexture(CCTexture2D *pTexture) { - assert(pTexture != NULL); + CCAssert(pTexture != NULL, ""); CCRect rect = CCRectZero; rect.size = pTexture->getContentSize(); @@ -245,7 +246,7 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture) bool CCSprite::initWithFile(const char *pszFilename) { - assert(pszFilename != NULL); + CCAssert(pszFilename != NULL, ""); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename); if (pTexture) @@ -263,7 +264,7 @@ bool CCSprite::initWithFile(const char *pszFilename) bool CCSprite::initWithFile(const char *pszFilename, const CCRect& rect) { - assert(pszFilename != NULL); + CCAssert(pszFilename != NULL, ""); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename); if (pTexture) @@ -279,7 +280,7 @@ bool CCSprite::initWithFile(const char *pszFilename, const CCRect& rect) bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame) { - assert(pSpriteFrame != NULL); + CCAssert(pSpriteFrame != NULL, ""); bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect()); setDisplayFrame(pSpriteFrame); @@ -289,7 +290,7 @@ bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame) bool CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName) { - assert(pszSpriteFrameName != NULL); + CCAssert(pszSpriteFrameName != NULL, ""); CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName); return initWithSpriteFrame(pFrame); @@ -309,7 +310,7 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage) /* CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey) { - assert(pImage != NULL); + CCAssert(pImage != NULL); // XXX: possible bug. See issue #349. New API should be added CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addCGImage(pImage, pszKey); @@ -495,7 +496,7 @@ void CCSprite::updateTextureCoords(const CCRect& rect) void CCSprite::updateTransform(void) { - assert(m_bUsesBatchNode); + CCAssert(m_bUsesBatchNode, ""); // optimization. Quick return if not dirty if (! m_bDirty) @@ -650,7 +651,7 @@ void CCSprite::draw(void) { CCNode::draw(); - assert(! m_bUsesBatchNode); + CCAssert(! m_bUsesBatchNode, ""); // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY @@ -726,12 +727,12 @@ void CCSprite::addChild(CCNode *pChild, int zOrder) void CCSprite::addChild(CCNode *pChild, int zOrder, int tag) { - assert(pChild != NULL); + CCAssert(pChild != NULL, ""); CCNode::addChild(pChild, zOrder, tag); if (m_bUsesBatchNode) { - assert(((CCSprite*)pChild)->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName()); + CCAssert(((CCSprite*)pChild)->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), ""); unsigned int index = m_pobBatchNode->atlasIndexForChild((CCSprite*)(pChild), zOrder); m_pobBatchNode->insertChild((CCSprite*)(pChild), index); } @@ -741,8 +742,8 @@ void CCSprite::addChild(CCNode *pChild, int zOrder, int tag) void CCSprite::reorderChild(CCNode *pChild, int zOrder) { - assert(pChild != NULL); - assert(m_pChildren->containsObject(pChild)); + CCAssert(pChild != NULL, ""); + CCAssert(m_pChildren->containsObject(pChild), ""); if (zOrder == pChild->getZOrder()) { @@ -888,7 +889,7 @@ void CCSprite::setAnchorPoint(const CCPoint& anchor) void CCSprite::setIsRelativeAnchorPoint(bool bRelative) { - assert(! m_bUsesBatchNode); + CCAssert(! m_bUsesBatchNode, ""); CCNode::setIsRelativeAnchorPoint(bRelative); } @@ -1032,15 +1033,15 @@ void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame) void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex) { - assert(animationName); + CCAssert(animationName, ""); CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName); - assert(a); + CCAssert(a, ""); CCSpriteFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex); - assert(frame); + CCAssert(frame, ""); setDisplayFrame(frame); } @@ -1066,8 +1067,7 @@ CCSpriteFrame* CCSprite::displayedFrame(void) void CCSprite::updateBlendFunc(void) { - // CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a CCSpriteSheet - assert (! m_bUsesBatchNode); + CCAssert (! m_bUsesBatchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a CCSpriteSheet"); // it's possible to have an untextured sprite if (! m_pobTexture || ! m_pobTexture->getHasPremultipliedAlpha()) @@ -1087,11 +1087,11 @@ void CCSprite::updateBlendFunc(void) void CCSprite::setTexture(CCTexture2D *texture) { // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet - assert(! m_bUsesBatchNode); + CCAssert(! m_bUsesBatchNode, "setTexture doesn't work when the sprite is rendered using a CCSpriteSheet"); // we can not use RTTI, so we do not known the type of object // accept texture==nil as argument - /*assert((! texture) || dynamic_cast(texture));*/ + /*CCAssert((! texture) || dynamic_cast(texture));*/ CC_SAFE_RELEASE(m_pobTexture); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index a6027c69f4..7aecb6a7f2 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -152,11 +152,11 @@ namespace cocos2d void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag) { - assert(child != NULL); + CCAssert(child != NULL, "child should not be null"); CCSprite *pSprite = (CCSprite*)(child); // check CCSprite is using the same texture id - assert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName()); + CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), ""); CCNode::addChild(child, zOrder, tag); @@ -177,8 +177,8 @@ namespace cocos2d // override reorderChild void CCSpriteBatchNode::reorderChild(CCNode *child, int zOrder) { - assert(child != NULL); - assert(m_pChildren->containsObject(child)); + CCAssert(child != NULL, "the child should not be null"); + CCAssert(m_pChildren->containsObject(child), "sprite batch node should contain the child"); if (zOrder == child->getZOrder()) { @@ -203,7 +203,7 @@ namespace cocos2d return; } - assert(m_pChildren->containsObject(pSprite)); + CCAssert(m_pChildren->containsObject(pSprite), "sprite batch node should contain the child"); // cleanup before removing removeSpriteFromAtlas(pSprite); @@ -307,7 +307,7 @@ namespace cocos2d { // serious problems CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); - assert(false); + CCAssert(false, "Not enough memory to resize the atla"); } } @@ -435,7 +435,7 @@ namespace cocos2d } // Should not happen. Error calculating Z on SpriteSheet - assert(0); + CCAssert(0, "should not run here"); return 0; } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index 48d4783a1d..fb4accc0e7 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -25,6 +25,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCSpriteFrame.h" +#include "CCDirector.h" namespace cocos2d { // implementation of CCSpriteFrame diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index b7eae23b38..9fd870a851 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -91,7 +91,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary=0 && format <= 3); + CCAssert(format >=0 && format <= 3, ""); framesDict->begin(); std::string key = ""; @@ -206,7 +206,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName) { - assert(textureFileName); + CCAssert(textureFileName, "texture name should not be null"); CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(textureFileName); if (texture) diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index b305dbf8c6..5ebc8956d6 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -41,7 +41,7 @@ THE SOFTWARE. #include #include #include - +#include "ccMacros.h" #include "CCObject.h" #include "ccMacros.h" diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index 5c800827e7..9f74a6cd55 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -143,8 +143,8 @@ namespace cocos2d int len; unsigned int offset = 0; - assert( out ); - assert( &*out ); + CCAssert(out, ""); + CCAssert(&*out, ""); gzFile inFile = gzopen(path, "rb"); if( inFile == NULL ) { @@ -210,8 +210,8 @@ namespace cocos2d int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) { - assert( out ); - assert( &*out ); + CCAssert(out, ""); + CCAssert(&*out, ""); // load file into memory unsigned char *compressed = NULL; diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 9b31db9f01..38de313b8d 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -41,6 +41,7 @@ THE SOFTWARE. #include "support/ccUtils.h" #include "platform/CCPlatformMacros.h" #include "CCTexturePVR.h" +#include "CCDirector.h" #if CC_ENABLE_CACHE_TEXTTURE_DATA #include "CCTextureCache.h" @@ -672,7 +673,7 @@ unsigned int CCTexture2D::bitsPerPixelForFormat() break; default: ret = -1; - assert(false); + CCAssert(false, "illegal pixel format"); CCLOG("bitsPerPixelForFormat: %d, cannot give useful result", m_ePixelFormat); break; } diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index ba07ea9ecc..0babdfa79d 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -141,7 +141,7 @@ bool CCTextureAtlas::initWithFile(const char * file, unsigned int capacity) bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity) { - assert(texture != NULL); + CCAssert(texture != NULL, "texture should not be null"); m_uCapacity = capacity; m_uTotalQuads = 0; @@ -150,7 +150,7 @@ bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity CC_SAFE_RETAIN(m_pTexture); // Re-initialization is not allowed - assert(m_pQuads == NULL && m_pIndices == NULL); + CCAssert(m_pQuads == NULL && m_pIndices == NULL, ""); m_pQuads = (ccV3F_C4B_T2F_Quad*)calloc( sizeof(ccV3F_C4B_T2F_Quad) * m_uCapacity, 1 ); m_pIndices = (GLushort *)calloc( sizeof(GLushort) * m_uCapacity * 6, 1 ); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index f417e9c464..4d09cb7b66 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "CCTextureCache.h" #include "CCPointExtension.h" #include "support/data_support/ccCArray.h" +#include "CCDirector.h" namespace cocos2d { diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index 7b87b7a95b..f1c8dcb57b 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -183,7 +183,7 @@ namespace cocos2d{ if( gid != 0 ) { // Optimization: quick return - // if the layer is invalid (more than 1 tileset per layer) an assert will be thrown later + // if the layer is invalid (more than 1 tileset per layer) an CCAssert will be thrown later if( gid >= tileset->m_uFirstGid ) return tileset; } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index a71ece4045..cd43bdd317 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -555,7 +555,7 @@ namespace cocos2d { int sizeHint = (int)(s.width * s.height * sizeof(unsigned int)); int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint); - assert(inflatedLen == sizeHint); + CCAssert(inflatedLen == sizeHint, ""); inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warings in compiler diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 9b48f529b6..ed4e73daaf 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -31,7 +31,6 @@ THE SOFTWARE. #include "CCTexture2D.h" #include "support/data_support/ccCArray.h" -#include #include /** @@ -131,7 +130,7 @@ void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, CCMutableArray if (h->getDelegate() == pHandler->getDelegate()) { - assert(0); + CCAssert(0, ""); return; } } @@ -269,13 +268,13 @@ void CCTouchDispatcher::rearrangeHandlers(CCMutableArray *pArra void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) { - assert(pDelegate != NULL); + CCAssert(pDelegate != NULL, ""); CCTouchHandler *handler = NULL; handler = this->findHandler(pDelegate); - assert(handler != NULL); + CCAssert(handler != NULL, ""); handler->setPriority(nPriority); @@ -288,7 +287,7 @@ void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) // void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int uIndex) { - assert(uIndex >= 0 && uIndex < 4); + CCAssert(uIndex >= 0 && uIndex < 4, ""); CCSet *pMutableTouches; m_bLocked = true; diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp index 58257ec863..8959eec2b3 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp @@ -88,7 +88,7 @@ CCTouchHandler* CCTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate, bool CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority) { - assert(pDelegate != NULL); + CCAssert(pDelegate != NULL, "touch delegate should not be null"); m_pDelegate = pDelegate; pDelegate->keep(); m_nPriority = nPriority; From 4bdd70ab90e51e2aec7e889341422326a607bc61 Mon Sep 17 00:00:00 2001 From: dumganhar Date: Tue, 29 Nov 2011 09:27:44 +0800 Subject: [PATCH 3/3] fixed #781: Add functions for effects --- CocosDenshion/bada/SimpleAudioEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CocosDenshion/bada/SimpleAudioEngine.cpp b/CocosDenshion/bada/SimpleAudioEngine.cpp index ab95d55269..f222cedb26 100644 --- a/CocosDenshion/bada/SimpleAudioEngine.cpp +++ b/CocosDenshion/bada/SimpleAudioEngine.cpp @@ -450,7 +450,7 @@ unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop/* if (AUDIOOUT_STATE_PLAYING == p->second->GetState()) { return nRet; // Stop waste a lot of time, so just return. - r = p->second->Stop(); + //r = p->second->Stop(); } if (s_fEffectsVolume > 0.0f)