Merge branch 'master' of https://github.com/cocos2d/cocos2d-x into issue850_Box2d2.2.1

This commit is contained in:
dumganhar 2011-11-29 12:42:25 +08:00
commit 5106f60131
48 changed files with 175 additions and 158 deletions

View File

@ -450,7 +450,7 @@ unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop/*
if (AUDIOOUT_STATE_PLAYING == p->second->GetState()) if (AUDIOOUT_STATE_PLAYING == p->second->GetState())
{ {
return nRet; // Stop waste a lot of time, so just return. return nRet; // Stop waste a lot of time, so just return.
r = p->second->Stop(); //r = p->second->Stop();
} }
if (s_fEffectsVolume > 0.0f) if (s_fEffectsVolume > 0.0f)

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#include "CCGL.h" #include "CCGL.h"
#include "CCDrawingPrimitives.h" #include "CCDrawingPrimitives.h"
#include "CCDirector.h"
using namespace std; using namespace std;
namespace cocos2d { namespace cocos2d {

View File

@ -156,7 +156,7 @@ CCDirector::~CCDirector(void)
void CCDirector::setGLDefaultValues(void) void CCDirector::setGLDefaultValues(void)
{ {
// This method SHOULD be called only after openGLView_ was initialized // This method SHOULD be called only after openGLView_ was initialized
assert(m_pobOpenGLView); CCAssert(m_pobOpenGLView, "opengl view should not be null");
setAlphaBlending(true); setAlphaBlending(true);
setDepthTest(true); setDepthTest(true);
@ -275,7 +275,7 @@ void CCDirector::calculateDeltaTime(void)
void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView) void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
{ {
assert(pobOpenGLView); CCAssert(pobOpenGLView, "opengl view should not be null");
if (m_pobOpenGLView != pobOpenGLView) if (m_pobOpenGLView != pobOpenGLView)
{ {
@ -494,8 +494,8 @@ void CCDirector::reshapeProjection(const CCSize& newWindowSize)
void CCDirector::runWithScene(CCScene *pScene) void CCDirector::runWithScene(CCScene *pScene)
{ {
assert(pScene != NULL); CCAssert(pScene != NULL, "running scene should not be null");
assert(m_pRunningScene == NULL); CCAssert(m_pRunningScene == NULL, "m_pRunningScene should be null");
pushScene(pScene); pushScene(pScene);
startAnimation(); startAnimation();
@ -503,7 +503,7 @@ void CCDirector::runWithScene(CCScene *pScene)
void CCDirector::replaceScene(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(); unsigned int index = m_pobScenesStack->count();
@ -515,7 +515,7 @@ void CCDirector::replaceScene(CCScene *pScene)
void CCDirector::pushScene(CCScene *pScene) void CCDirector::pushScene(CCScene *pScene)
{ {
assert(pScene); CCAssert(pScene, "the scene should not null");
m_bSendCleanupToScene = false; m_bSendCleanupToScene = false;
@ -525,7 +525,7 @@ void CCDirector::pushScene(CCScene *pScene)
void CCDirector::popScene(void) void CCDirector::popScene(void)
{ {
assert(m_pRunningScene != NULL); CCAssert(m_pRunningScene != NULL, "running scene should not null");
m_pobScenesStack->removeLastObject(); m_pobScenesStack->removeLastObject();
unsigned int c = m_pobScenesStack->count(); unsigned int c = m_pobScenesStack->count();

View File

@ -28,10 +28,10 @@ THE SOFTWARE.
#include "ccTypes.h" #include "ccTypes.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "CCGL.h" #include "CCGL.h"
#include "CCDirector.h"
#include <string.h> #include <string.h>
#include <cmath> #include <cmath>
#include "CCGL.h"
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846

View File

@ -31,8 +31,6 @@ THE SOFTWARE.
#include "CCMutableArray.h" #include "CCMutableArray.h"
#include "CCScriptSupport.h" #include "CCScriptSupport.h"
#include <assert.h>
using namespace std; using namespace std;
namespace cocos2d { namespace cocos2d {
@ -189,7 +187,7 @@ CCScheduler::CCScheduler(void)
, m_bCurrentTargetSalvaged(false) , m_bCurrentTargetSalvaged(false)
, m_pHashForScriptFunctions(NULL) , m_pHashForScriptFunctions(NULL)
{ {
assert(pSharedScheduler == NULL); CCAssert(pSharedScheduler == NULL, "");
} }
CCScheduler::~CCScheduler(void) CCScheduler::~CCScheduler(void)
@ -245,8 +243,8 @@ void CCScheduler::removeHashElement(_hashSelectorEntry *pElement)
void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget, float fInterval, bool bPaused) void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget, float fInterval, bool bPaused)
{ {
assert(pfnSelector); CCAssert(pfnSelector, "");
assert(pTarget); CCAssert(pTarget, "");
tHashSelectorEntry *pElement = NULL; tHashSelectorEntry *pElement = NULL;
HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement);
@ -266,7 +264,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *p
} }
else else
{ {
assert(pElement->paused == bPaused); CCAssert(pElement->paused == bPaused, "");
} }
if (pElement->timers == NULL) 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) void CCScheduler::scheduleScriptFunc(const char *pszFuncName, ccTime fInterval, bool bPaused)
{ {
//assert(pfnSelector); //CCAssert(pfnSelector);
assert(pszFuncName); CCAssert(pszFuncName, "");
tHashScriptFuncEntry *pElement = NULL; tHashScriptFuncEntry *pElement = NULL;
HASH_FIND_INT(m_pHashForScriptFunctions, &pszFuncName, pElement); HASH_FIND_INT(m_pHashForScriptFunctions, &pszFuncName, pElement);
@ -315,7 +313,7 @@ void CCScheduler::scheduleScriptFunc(const char *pszFuncName, ccTime fInterval,
} }
else else
{ {
assert(pElement->paused == bPaused); CCAssert(pElement->paused == bPaused, "");
} }
} }
@ -327,8 +325,8 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol
return; return;
} }
//assert(pTarget); //CCAssert(pTarget);
//assert(pfnSelector); //CCAssert(pfnSelector);
tHashSelectorEntry *pElement = NULL; tHashSelectorEntry *pElement = NULL;
HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement);
@ -477,7 +475,7 @@ void CCScheduler::scheduleUpdateForTarget(SelectorProtocol *pTarget, int nPriori
if (pHashElement) if (pHashElement)
{ {
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
assert(pHashElement->entry->markedForDeletion); CCAssert(pHashElement->entry->markedForDeletion);
#endif #endif
// TODO: check if priority has changed! // TODO: check if priority has changed!
@ -620,7 +618,7 @@ void CCScheduler::unscheduleAllSelectorsForTarget(SelectorProtocol *pTarget)
void CCScheduler::resumeTarget(SelectorProtocol *pTarget) void CCScheduler::resumeTarget(SelectorProtocol *pTarget)
{ {
assert(pTarget != NULL); CCAssert(pTarget != NULL, "");
// custom selectors // custom selectors
tHashSelectorEntry *pElement = NULL; tHashSelectorEntry *pElement = NULL;
@ -635,14 +633,14 @@ void CCScheduler::resumeTarget(SelectorProtocol *pTarget)
HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate); HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate);
if (pElementUpdate) if (pElementUpdate)
{ {
assert(pElementUpdate->entry != NULL); CCAssert(pElementUpdate->entry != NULL, "");
pElementUpdate->entry->paused = false; pElementUpdate->entry->paused = false;
} }
} }
void CCScheduler::pauseTarget(SelectorProtocol *pTarget) void CCScheduler::pauseTarget(SelectorProtocol *pTarget)
{ {
assert(pTarget != NULL); CCAssert(pTarget != NULL, "");
// custom selectors // custom selectors
tHashSelectorEntry *pElement = NULL; tHashSelectorEntry *pElement = NULL;
@ -657,7 +655,7 @@ void CCScheduler::pauseTarget(SelectorProtocol *pTarget)
HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate); HASH_FIND_INT(m_pHashForUpdates, &pTarget, pElementUpdate);
if (pElementUpdate) if (pElementUpdate)
{ {
assert(pElementUpdate->entry != NULL); CCAssert(pElementUpdate->entry != NULL, "");
pElementUpdate->entry->paused = true; pElementUpdate->entry->paused = true;
} }
} }

View File

@ -137,7 +137,7 @@ CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fRate)
bool CCSpeed::initWithAction(CCActionInterval *pAction, float fRate) bool CCSpeed::initWithAction(CCActionInterval *pAction, float fRate)
{ {
assert(pAction != NULL); CCAssert(pAction != NULL, "");
pAction->retain(); pAction->retain();
m_pInnerAction = pAction; m_pInnerAction = pAction;
m_fSpeed = fRate; m_fSpeed = fRate;
@ -235,7 +235,7 @@ CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect)
bool CCFollow::initWithTarget(CCNode *pFollowedNode) bool CCFollow::initWithTarget(CCNode *pFollowedNode)
{ {
assert(pFollowedNode != NULL); CCAssert(pFollowedNode != NULL, "");
pFollowedNode->retain(); pFollowedNode->retain();
m_pobFollowedNode = pFollowedNode; m_pobFollowedNode = pFollowedNode;
m_bBoundarySet = false; m_bBoundarySet = false;
@ -249,7 +249,7 @@ bool CCFollow::initWithTarget(CCNode *pFollowedNode)
bool CCFollow::initWithTarget(CCNode *pFollowedNode, const CCRect& rect) bool CCFollow::initWithTarget(CCNode *pFollowedNode, const CCRect& rect)
{ {
assert(pFollowedNode != NULL); CCAssert(pFollowedNode != NULL, "");
pFollowedNode->retain(); pFollowedNode->retain();
m_pobFollowedNode = pFollowedNode; m_pobFollowedNode = pFollowedNode;
m_bBoundarySet = true; m_bBoundarySet = true;

View File

@ -62,7 +62,7 @@ namespace cocos2d {
bool CCActionEase::initWithAction(CCActionInterval *pAction) bool CCActionEase::initWithAction(CCActionInterval *pAction)
{ {
assert(pAction != NULL); CCAssert(pAction != NULL, "");
if (CCActionInterval::initWithDuration(pAction->getDuration())) if (CCActionInterval::initWithDuration(pAction->getDuration()))
{ {
@ -740,7 +740,7 @@ namespace cocos2d {
CCActionInterval* CCEaseElastic::reverse(void) CCActionInterval* CCEaseElastic::reverse(void)
{ {
assert(0); CCAssert(0, "");
return NULL; return NULL;
} }

View File

@ -78,7 +78,7 @@ namespace cocos2d
} }
else else
{ {
assert(0); CCAssert(0, "");
} }
} }
else else
@ -96,7 +96,7 @@ namespace cocos2d
CCGridBase* CCGridAction::getGrid(void) CCGridBase* CCGridAction::getGrid(void)
{ {
// Abstract class needs implementation // Abstract class needs implementation
assert(0); CCAssert(0, "");
return NULL; return NULL;
} }

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCActionGrid3D.h" #include "CCActionGrid3D.h"
#include "CCPointExtension.h" #include "CCPointExtension.h"
#include "CCDirector.h"
#include <stdlib.h> #include <stdlib.h>
@ -134,7 +135,7 @@ namespace cocos2d
if (gridSize.x != 1 || gridSize.y != 1) if (gridSize.x != 1 || gridSize.y != 1)
{ {
// Grid size must be (1,1) // Grid size must be (1,1)
assert(0); CCAssert(0, "");
return false; return false;
} }

View File

@ -76,7 +76,7 @@ CCObject* CCActionInterval::copyWithZone(CCZone *pZone)
else else
{ {
// action's base class , must be called using __super::copyWithZone(), after overriding from derived class // action's base class , must be called using __super::copyWithZone(), after overriding from derived class
assert(0); CCAssert(0, "");
pCopy = new CCActionInterval(); pCopy = new CCActionInterval();
pZone = pNewZone = new CCZone(pCopy); pZone = pNewZone = new CCZone(pCopy);
@ -117,13 +117,13 @@ void CCActionInterval::setAmplitudeRate(CGFloat amp)
{ {
CC_UNUSED_PARAM(amp); CC_UNUSED_PARAM(amp);
// Abstract class needs implementation // Abstract class needs implementation
assert(0); CCAssert(0, "");
} }
CGFloat CCActionInterval::getAmplitudeRate(void) CGFloat CCActionInterval::getAmplitudeRate(void)
{ {
// Abstract class needs implementation // Abstract class needs implementation
assert(0); CCAssert(0, "");
return 0; return 0;
} }
@ -198,8 +198,8 @@ CCFiniteTimeAction* CCSequence::actionsWithArray(CCArray *actions)
bool CCSequence::initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) bool CCSequence::initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo)
{ {
assert(pActionOne != NULL); CCAssert(pActionOne != NULL, "");
assert(pActionTwo != NULL); CCAssert(pActionTwo != NULL, "");
ccTime d = pActionOne->getDuration() + pActionTwo->getDuration(); ccTime d = pActionOne->getDuration() + pActionTwo->getDuration();
CCActionInterval::initWithDuration(d); CCActionInterval::initWithDuration(d);
@ -459,7 +459,7 @@ CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction)
bool CCRepeatForever::initWithAction(CCActionInterval *pAction) bool CCRepeatForever::initWithAction(CCActionInterval *pAction)
{ {
assert(pAction != NULL); CCAssert(pAction != NULL, "");
pAction->retain(); pAction->retain();
m_pInnerAction = pAction; m_pInnerAction = pAction;
return true; return true;
@ -563,8 +563,8 @@ CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction
bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2)
{ {
assert(pAction1 != NULL); CCAssert(pAction1 != NULL, "");
assert(pAction2 != NULL); CCAssert(pAction2 != NULL, "");
bool bRet = false; bool bRet = false;
@ -1941,8 +1941,8 @@ CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction)
bool CCReverseTime::initWithAction(CCFiniteTimeAction *pAction) bool CCReverseTime::initWithAction(CCFiniteTimeAction *pAction)
{ {
assert(pAction != NULL); CCAssert(pAction != NULL, "");
assert(pAction != m_pOther); CCAssert(pAction != m_pOther, "");
if (CCActionInterval::initWithDuration(pAction->getDuration())) if (CCActionInterval::initWithDuration(pAction->getDuration()))
{ {
@ -2030,7 +2030,7 @@ CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation)
bool CCAnimate::initWithAnimation(CCAnimation *pAnimation) bool CCAnimate::initWithAnimation(CCAnimation *pAnimation)
{ {
assert(pAnimation != NULL); CCAssert(pAnimation != NULL, "");
return initWithAnimation(pAnimation, true); return initWithAnimation(pAnimation, true);
} }
@ -2046,7 +2046,7 @@ CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation, bool bRestore
bool CCAnimate::initWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame) bool CCAnimate::initWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame)
{ {
assert(pAnimation); CCAssert(pAnimation, "");
if (CCActionInterval::initWithDuration(pAnimation->getFrames()->count() * pAnimation->getDelay())) 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) bool CCAnimate::initWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame)
{ {
assert(pAnimation != NULL); CCAssert(pAnimation != NULL, "");
if (CCActionInterval::initWithDuration(duration)) if (CCActionInterval::initWithDuration(duration))
{ {

View File

@ -89,7 +89,7 @@ CCActionManager::CCActionManager(void)
m_pCurrentTarget(NULL), m_pCurrentTarget(NULL),
m_bCurrentTargetSalvaged(false) m_bCurrentTargetSalvaged(false)
{ {
assert(gSharedManager == NULL); CCAssert(gSharedManager == NULL, "");
} }
CCActionManager::~CCActionManager(void) CCActionManager::~CCActionManager(void)
@ -191,8 +191,8 @@ void CCActionManager::resumeTarget(CCObject *pTarget)
void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused) void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused)
{ {
assert(pAction != NULL); CCAssert(pAction != NULL, "");
assert(pTarget != NULL); CCAssert(pTarget != NULL, "");
tHashElement *pElement = NULL; tHashElement *pElement = NULL;
// we should convert it to CCObject*, because we save it as CCObject* // 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); actionAllocWithHashElement(pElement);
assert(! ccArrayContainsObject(pElement->actions, pAction)); CCAssert(! ccArrayContainsObject(pElement->actions, pAction), "");
ccArrayAppendObject(pElement->actions, pAction); ccArrayAppendObject(pElement->actions, pAction);
pAction->startWithTarget(pTarget); pAction->startWithTarget(pTarget);
@ -288,8 +288,8 @@ void CCActionManager::removeAction(CCAction *pAction)
void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget) void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget)
{ {
assert((int)tag != kCCActionTagInvalid); CCAssert((int)tag != kCCActionTagInvalid, "");
assert(pTarget != NULL); CCAssert(pTarget != NULL, "");
tHashElement *pElement = NULL; tHashElement *pElement = NULL;
HASH_FIND_INT(m_pTargets, &pTarget, pElement); 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) CCAction* CCActionManager::getActionByTag(unsigned int tag, CCObject *pTarget)
{ {
assert((int)tag != kCCActionTagInvalid); CCAssert((int)tag != kCCActionTagInvalid, "");
tHashElement *pElement = NULL; tHashElement *pElement = NULL;
HASH_FIND_INT(m_pTargets, &pTarget, pElement); HASH_FIND_INT(m_pTargets, &pTarget, pElement);

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include "CCAtlasNode.h" #include "CCAtlasNode.h"
#include "CCTextureAtlas.h" #include "CCTextureAtlas.h"
#include "CCDirector.h"
namespace cocos2d { 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, bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight,
unsigned int itemsToRender) unsigned int itemsToRender)
{ {
assert(tile != NULL); CCAssert(tile != NULL, "title should not be null");
m_uItemWidth = (int) (tileWidth * CC_CONTENT_SCALE_FACTOR()); m_uItemWidth = (int) (tileWidth * CC_CONTENT_SCALE_FACTOR());
m_uItemHeight = (int) (tileHeight * CC_CONTENT_SCALE_FACTOR()); m_uItemHeight = (int) (tileHeight * CC_CONTENT_SCALE_FACTOR());

View File

@ -718,7 +718,7 @@ void CCNode::reorderChild(CCNode *child, int zOrder)
void CCNode::draw() void CCNode::draw()
{ {
//assert(0); //CCAssert(0);
// override me // override me
// Only use- this function to draw your staff. // Only use- this function to draw your staff.
// DON'T draw your stuff outside this method // DON'T draw your stuff outside this method

View File

@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCAutoreleasePool.h" #include "CCAutoreleasePool.h"
#include "ccMacros.h"
namespace cocos2d namespace cocos2d
{ {
@ -42,7 +43,7 @@ void CCAutoreleasePool::addObject(CCObject* pObject)
{ {
m_pManagedObjectArray->addObject(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. pObject->release(); // no ref count, in this case autorelease pool added.
} }
@ -162,7 +163,7 @@ void CCPoolManager::pop()
void CCPoolManager::removeObject(CCObject* pObject) void CCPoolManager::removeObject(CCObject* pObject)
{ {
assert(m_pCurReleasePool); CCAssert(m_pCurReleasePool, "current auto release pool should not be null");
m_pCurReleasePool->removeObject(pObject); m_pCurReleasePool->removeObject(pObject);
} }
@ -176,9 +177,11 @@ void CCPoolManager::addObject(CCObject* pObject)
CCAutoreleasePool* CCPoolManager::getCurReleasePool() CCAutoreleasePool* CCPoolManager::getCurReleasePool()
{ {
if(!m_pCurReleasePool) if(!m_pCurReleasePool)
{
push(); push();
}
assert(m_pCurReleasePool); CCAssert(m_pCurReleasePool, "current auto release pool should not be null");
return m_pCurReleasePool; return m_pCurReleasePool;
} }

View File

@ -25,14 +25,14 @@ THE SOFTWARE.
#include "CCObject.h" #include "CCObject.h"
#include "CCAutoreleasePool.h" #include "CCAutoreleasePool.h"
#include <assert.h> #include "ccMacros.h"
namespace cocos2d { namespace cocos2d {
CCObject* CCCopying::copyWithZone(CCZone *pZone) CCObject* CCCopying::copyWithZone(CCZone *pZone)
{ {
CC_UNUSED_PARAM(pZone); CC_UNUSED_PARAM(pZone);
assert(0); CCAssert(0, "not implement");
return 0; return 0;
} }
@ -64,7 +64,7 @@ CCObject* CCObject::copy()
void CCObject::release(void) void CCObject::release(void)
{ {
assert(m_uReference > 0); CCAssert(m_uReference > 0, "reference count should greater than 0");
--m_uReference; --m_uReference;
if (m_uReference == 0) if (m_uReference == 0)
@ -75,7 +75,7 @@ void CCObject::release(void)
void CCObject::retain(void) void CCObject::retain(void)
{ {
assert(m_uReference > 0); CCAssert(m_uReference > 0, "reference count should greater than 0");
++m_uReference; ++m_uReference;
} }

View File

@ -274,17 +274,17 @@ namespace cocos2d
void CCGridBase::blit(void) void CCGridBase::blit(void)
{ {
assert(0); CCAssert(0, "");
} }
void CCGridBase::reuse(void) void CCGridBase::reuse(void)
{ {
assert(0); CCAssert(0, "");
} }
void CCGridBase::calculateVertexPoints(void) void CCGridBase::calculateVertexPoints(void)
{ {
assert(0); CCAssert(0, "");
} }
// implementation of CCGrid3D // implementation of CCGrid3D

View File

@ -32,6 +32,7 @@ THE SOFTWARE.
#include "CCTouchDelegateProtocol.h" #include "CCTouchDelegateProtocol.h"
#include "CCAccelerometerDelegate.h" #include "CCAccelerometerDelegate.h"
#include "CCKeypadDelegate.h" #include "CCKeypadDelegate.h"
#include "CCMutableArray.h"
namespace cocos2d { namespace cocos2d {

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include "CCNode.h" #include "CCNode.h"
#include "CCProtocols.h" #include "CCProtocols.h"
#include "selector_protocol.h" #include "selector_protocol.h"
#include "CCMutableArray.h"
namespace cocos2d{ namespace cocos2d{

View File

@ -26,8 +26,8 @@ THE SOFTWARE.
#define __COCOA_CC_MUTABLE_ARRAY_H__ #define __COCOA_CC_MUTABLE_ARRAY_H__
#include "CCObject.h" #include "CCObject.h"
#include "ccMacros.h"
#include <vector> #include <vector>
#include <assert.h>
#include <stdarg.h> #include <stdarg.h>
namespace cocos2d { namespace cocos2d {
@ -113,7 +113,7 @@ public:
T getObjectAtIndex(unsigned int uIndex) T getObjectAtIndex(unsigned int uIndex)
{ {
assert(uIndex < count()); CCAssert(uIndex < count(), "");
if (uIndex >= count()) if (uIndex >= count())
{ {
@ -155,7 +155,7 @@ public:
void insertObjectAtIndex(T pObject, unsigned int uIndex) void insertObjectAtIndex(T pObject, unsigned int uIndex)
{ {
assert(uIndex <= count()); CCAssert(uIndex <= count(), "");
// make sure the object is not null // make sure the object is not null
if (pObject == 0) if (pObject == 0)
{ {

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
/*#include <GLES/egl.h>*/ /*#include <GLES/egl.h>*/
#include "CCNode.h" #include "CCNode.h"
#include "CCProtocols.h" #include "CCProtocols.h"
#include "CCMutableArray.h"
namespace cocos2d { namespace cocos2d {

View File

@ -135,7 +135,6 @@ default gl blend src function. Compatible with premultiplied alpha images.
On Mac it returns 1; On Mac it returns 1;
On iPhone it returns 2 if RetinaDisplay is On. Otherwise 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() #define CC_CONTENT_SCALE_FACTOR() CCDirector::sharedDirector()->getContentScaleFactor()

View File

@ -46,7 +46,7 @@ namespace cocos2d{
bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) 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))) if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label)))
{ {
m_cMapStartChar = startCharMap; m_cMapStartChar = startCharMap;

View File

@ -102,7 +102,7 @@ namespace cocos2d{
} }
bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile) bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile)
{ {
assert(FNTfile != NULL && strlen(FNTfile)!=0); CCAssert(FNTfile != NULL && strlen(FNTfile)!=0, "");
m_pKerningDictionary = NULL; m_pKerningDictionary = NULL;
this->parseConfigFile(FNTfile); this->parseConfigFile(FNTfile);
return true; return true;
@ -395,7 +395,7 @@ namespace cocos2d{
bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile)
{ {
assert(theString != NULL); CCAssert(theString != NULL, "");
CC_SAFE_RELEASE(m_pConfiguration);// allow re-init CC_SAFE_RELEASE(m_pConfiguration);// allow re-init
m_pConfiguration = FNTConfigLoadFile(fntFile); m_pConfiguration = FNTConfigLoadFile(fntFile);
m_pConfiguration->retain(); m_pConfiguration->retain();

View File

@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCLabelTTF.h" #include "CCLabelTTF.h"
#include "CCDirector.h"
namespace cocos2d{ namespace cocos2d{
// //
@ -67,7 +68,7 @@ namespace cocos2d{
bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) 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()) if (CCSprite::init())
{ {
m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() ); 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) bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
{ {
assert(label != NULL); CCAssert(label != NULL, "");
if (CCSprite::init()) if (CCSprite::init())
{ {
m_tDimensions = CCSizeZero; m_tDimensions = CCSizeZero;

View File

@ -665,7 +665,7 @@ CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer)
} }
void CCLayerMultiplex::addLayer(CCLayer* layer) void CCLayerMultiplex::addLayer(CCLayer* layer)
{ {
assert(m_pLayers); CCAssert(m_pLayers, "");
m_pLayers->addObject(layer); m_pLayers->addObject(layer);
} }

View File

@ -357,11 +357,11 @@ namespace cocos2d{
CCNode* pChild = (CCNode*) pObject; CCNode* pChild = (CCNode*) pObject;
if (pChild) if (pChild)
{ {
assert(row < rows.size()); CCAssert(row < rows.size(), "");
rowColumns = rows[row]; rowColumns = rows[row];
// can not have zero columns on a row // can not have zero columns on a row
assert(rowColumns); CCAssert(rowColumns, "");
float tmp = pChild->getContentSize().height; float tmp = pChild->getContentSize().height;
rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); 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 // check if too many rows/columns for available menu items
assert(! columnsOccupied); CCAssert(! columnsOccupied, "");
CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSize winSize = CCDirector::sharedDirector()->getWinSize();
@ -467,11 +467,11 @@ namespace cocos2d{
if (pChild) if (pChild)
{ {
// check if too many menu items for the amount of rows/columns // check if too many menu items for the amount of rows/columns
assert(column < columns.size()); CCAssert(column < columns.size(), "");
columnRows = columns[column]; columnRows = columns[column];
// can't have zero rows on a column // can't have zero rows on a column
assert(columnRows); CCAssert(columnRows, "");
// columnWidth = fmaxf(columnWidth, [item contentSize].width); // columnWidth = fmaxf(columnWidth, [item contentSize].width);
float tmp = pChild->getContentSize().width; float tmp = pChild->getContentSize().width;
@ -496,7 +496,7 @@ namespace cocos2d{
} }
// check if too many rows/columns for available menu items. // check if too many rows/columns for available menu items.
assert(! rowsOccupied); CCAssert(! rowsOccupied, "");
CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSize winSize = CCDirector::sharedDirector()->getWinSize();

View File

@ -498,7 +498,7 @@ namespace cocos2d{
} }
bool CCMenuItemSprite::initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector) bool CCMenuItemSprite::initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector)
{ {
assert(normalSprite != NULL); CCAssert(normalSprite != NULL, "");
CCMenuItem::initWithTarget(target, selector); CCMenuItem::initWithTarget(target, selector);
setNormalImage(normalSprite); setNormalImage(normalSprite);
setSelectedImage(selectedSprite); setSelectedImage(selectedSprite);

View File

@ -343,7 +343,7 @@ void CCProgressTimer::updateRadial(void)
{ {
m_nVertexDataCount = index + 3; m_nVertexDataCount = index + 3;
m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount]; m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount];
assert(m_pVertexData); CCAssert(m_pVertexData, "");
updateColor(); updateColor();
} }
@ -432,7 +432,7 @@ void CCProgressTimer::updateBar(void)
{ {
m_nVertexDataCount = kProgressTextureCoordsCount; m_nVertexDataCount = kProgressTextureCoordsCount;
m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount]; m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount];
assert(m_pVertexData); CCAssert(m_pVertexData, "");
if (m_eType == kCCProgressTimerTypeHorizontalBarLR) if (m_eType == kCCProgressTimerTypeHorizontalBarLR)
{ {

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include "CCRibbon.h" #include "CCRibbon.h"
#include "CCTextureCache.h" #include "CCTextureCache.h"
#include "CCPointExtension.h" #include "CCPointExtension.h"
#include "CCDirector.h"
namespace cocos2d { namespace cocos2d {

View File

@ -50,6 +50,7 @@ THE SOFTWARE.
#include "CCImage.h" #include "CCImage.h"
#include "platform/platform.h" #include "platform/platform.h"
#include "support/zip_support/ZipUtils.h" #include "support/zip_support/ZipUtils.h"
#include "CCDirector.h"
// opengl // opengl
#include "platform/CCGL.h" #include "platform/CCGL.h"
@ -291,7 +292,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
else else
{ {
char *textureData = (char*)valueForKey("textureImageData", dictionary); char *textureData = (char*)valueForKey("textureImageData", dictionary);
assert(textureData); CCAssert(textureData, "");
int dataLen = strlen(textureData); int dataLen = strlen(textureData);
if(dataLen != 0) if(dataLen != 0)

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include "CCParticleSystemQuad.h" #include "CCParticleSystemQuad.h"
#include "CCSpriteFrame.h" #include "CCSpriteFrame.h"
#include "CCDirector.h"
namespace cocos2d { namespace cocos2d {

View File

@ -23,6 +23,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCFileUtils.h" #include "CCFileUtils.h"
#include "CCDirector.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY) #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)

View File

@ -146,12 +146,12 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
[self release]; [self release];
return nil; return nil;
} }
touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL);
indexBitsUsed = 0x00000000;
view = self;
} }
touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL);
indexBitsUsed = 0x00000000;
view = self;
return self; return self;
} }
@ -398,30 +398,33 @@ static cocos2d::CCTouch *s_pTouches[MAX_TOUCHES];
cocos2d::CCTouch *pTouch; cocos2d::CCTouch *pTouch;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch);
int unUsedIndex = 0; int unUsedIndex = 0;
// it is a new touch // it is a new touch
if (! index) { if (! index) {
unUsedIndex = [self getUnUsedIndex]; unUsedIndex = [self getUnUsedIndex];
// The touches is more than MAX_TOUCHES ? // The touches is more than MAX_TOUCHES ?
if (unUsedIndex == -1) { if (unUsedIndex == -1) {
return; return;
} }
pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch(); pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();
} float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
float x = [touch locationInView: [touch view]].x; pTouch->SetTouchInfo(0, x, y);
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); cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesBegan(&set);
} }

View File

@ -23,6 +23,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "windows.h" #include "windows.h"
#include "CCDirector.h"
using namespace std; using namespace std;

View File

@ -59,10 +59,10 @@
<listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/libjpeg/sdk2.0/.Target-Debug/libjpeg.a"/> <listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/libjpeg/sdk2.0/.Target-Debug/libjpeg.a"/>
<listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/png/sdk2.0/.Target-Debug/libpng.a"/> <listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/png/sdk2.0/.Target-Debug/libpng.a"/>
<listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/zlib/sdk2.0/.Target-Debug/libzlib.a"/> <listOptionValue builtIn="false" value="../../../platform/third_party/bada/src/zlib/sdk2.0/.Target-Debug/libzlib.a"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/pthread.so&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FOsp.so&quot;"/> <listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FOsp.so&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FGraphicsOpengl.so&quot;"/> <listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FGraphicsOpengl.so&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FGraphicsEgl.so&quot;"/> <listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/FGraphicsEgl.so&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/pthread.so&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/StubDynCast.so&quot;"/> <listOptionValue builtIn="false" value="&quot;${TARGET_LIB_PATH}/StubDynCast.so&quot;"/>
</option> </option>
<option id="osp.gnu.target.cpp.link.debug.so.option.libs.paths.1907274854" name="Library search path (-L)" superClass="osp.gnu.target.cpp.link.debug.so.option.libs.paths" valueType="libPaths"> <option id="osp.gnu.target.cpp.link.debug.so.option.libs.paths.1907274854" name="Library search path (-L)" superClass="osp.gnu.target.cpp.link.debug.so.option.libs.paths" valueType="libPaths">

View File

@ -37,6 +37,7 @@ THE SOFTWARE.
#include "CCGeometry.h" #include "CCGeometry.h"
#include "CCTexture2D.h" #include "CCTexture2D.h"
#include "CCAffineTransform.h" #include "CCAffineTransform.h"
#include "CCDirector.h"
#include <string.h> #include <string.h>
@ -123,7 +124,7 @@ CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect,
CC_UNUSED_PARAM(rect); CC_UNUSED_PARAM(rect);
CC_UNUSED_PARAM(offset); CC_UNUSED_PARAM(offset);
// not implement // not implement
assert(0); CCAssert(0, "");
return NULL; return NULL;
} }
@ -224,7 +225,7 @@ bool CCSprite::init(void)
bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect) bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect)
{ {
assert(pTexture != NULL); CCAssert(pTexture != NULL, "");
// IMPORTANT: [self init] and not [super init]; // IMPORTANT: [self init] and not [super init];
init(); init();
setTexture(pTexture); setTexture(pTexture);
@ -235,7 +236,7 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect)
bool CCSprite::initWithTexture(CCTexture2D *pTexture) bool CCSprite::initWithTexture(CCTexture2D *pTexture)
{ {
assert(pTexture != NULL); CCAssert(pTexture != NULL, "");
CCRect rect = CCRectZero; CCRect rect = CCRectZero;
rect.size = pTexture->getContentSize(); rect.size = pTexture->getContentSize();
@ -245,7 +246,7 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture)
bool CCSprite::initWithFile(const char *pszFilename) bool CCSprite::initWithFile(const char *pszFilename)
{ {
assert(pszFilename != NULL); CCAssert(pszFilename != NULL, "");
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename);
if (pTexture) if (pTexture)
@ -263,7 +264,7 @@ bool CCSprite::initWithFile(const char *pszFilename)
bool CCSprite::initWithFile(const char *pszFilename, const CCRect& rect) bool CCSprite::initWithFile(const char *pszFilename, const CCRect& rect)
{ {
assert(pszFilename != NULL); CCAssert(pszFilename != NULL, "");
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFilename);
if (pTexture) if (pTexture)
@ -279,7 +280,7 @@ bool CCSprite::initWithFile(const char *pszFilename, const CCRect& rect)
bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame) bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
{ {
assert(pSpriteFrame != NULL); CCAssert(pSpriteFrame != NULL, "");
bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect()); bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect());
setDisplayFrame(pSpriteFrame); setDisplayFrame(pSpriteFrame);
@ -289,7 +290,7 @@ bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
bool CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName) bool CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName)
{ {
assert(pszSpriteFrameName != NULL); CCAssert(pszSpriteFrameName != NULL, "");
CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName); CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);
return initWithSpriteFrame(pFrame); return initWithSpriteFrame(pFrame);
@ -309,7 +310,7 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage)
/* /*
CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey) 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 // XXX: possible bug. See issue #349. New API should be added
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addCGImage(pImage, pszKey); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addCGImage(pImage, pszKey);
@ -495,7 +496,7 @@ void CCSprite::updateTextureCoords(const CCRect& rect)
void CCSprite::updateTransform(void) void CCSprite::updateTransform(void)
{ {
assert(m_bUsesBatchNode); CCAssert(m_bUsesBatchNode, "");
// optimization. Quick return if not dirty // optimization. Quick return if not dirty
if (! m_bDirty) if (! m_bDirty)
@ -650,7 +651,7 @@ void CCSprite::draw(void)
{ {
CCNode::draw(); CCNode::draw();
assert(! m_bUsesBatchNode); CCAssert(! m_bUsesBatchNode, "");
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // 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 // 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) void CCSprite::addChild(CCNode *pChild, int zOrder, int tag)
{ {
assert(pChild != NULL); CCAssert(pChild != NULL, "");
CCNode::addChild(pChild, zOrder, tag); CCNode::addChild(pChild, zOrder, tag);
if (m_bUsesBatchNode) 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); unsigned int index = m_pobBatchNode->atlasIndexForChild((CCSprite*)(pChild), zOrder);
m_pobBatchNode->insertChild((CCSprite*)(pChild), index); 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) void CCSprite::reorderChild(CCNode *pChild, int zOrder)
{ {
assert(pChild != NULL); CCAssert(pChild != NULL, "");
assert(m_pChildren->containsObject(pChild)); CCAssert(m_pChildren->containsObject(pChild), "");
if (zOrder == pChild->getZOrder()) if (zOrder == pChild->getZOrder())
{ {
@ -888,7 +889,7 @@ void CCSprite::setAnchorPoint(const CCPoint& anchor)
void CCSprite::setIsRelativeAnchorPoint(bool bRelative) void CCSprite::setIsRelativeAnchorPoint(bool bRelative)
{ {
assert(! m_bUsesBatchNode); CCAssert(! m_bUsesBatchNode, "");
CCNode::setIsRelativeAnchorPoint(bRelative); CCNode::setIsRelativeAnchorPoint(bRelative);
} }
@ -1032,15 +1033,15 @@ void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame)
void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex) void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{ {
assert(animationName); CCAssert(animationName, "");
CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName); CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName);
assert(a); CCAssert(a, "");
CCSpriteFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex); CCSpriteFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex);
assert(frame); CCAssert(frame, "");
setDisplayFrame(frame); setDisplayFrame(frame);
} }
@ -1066,8 +1067,7 @@ CCSpriteFrame* CCSprite::displayedFrame(void)
void CCSprite::updateBlendFunc(void) void CCSprite::updateBlendFunc(void)
{ {
// CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a CCSpriteSheet CCAssert (! m_bUsesBatchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a CCSpriteSheet");
assert (! m_bUsesBatchNode);
// it's possible to have an untextured sprite // it's possible to have an untextured sprite
if (! m_pobTexture || ! m_pobTexture->getHasPremultipliedAlpha()) if (! m_pobTexture || ! m_pobTexture->getHasPremultipliedAlpha())
@ -1087,11 +1087,11 @@ void CCSprite::updateBlendFunc(void)
void CCSprite::setTexture(CCTexture2D *texture) 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_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 // we can not use RTTI, so we do not known the type of object
// accept texture==nil as argument // accept texture==nil as argument
/*assert((! texture) || dynamic_cast<CCTexture2D*>(texture));*/ /*CCAssert((! texture) || dynamic_cast<CCTexture2D*>(texture));*/
CC_SAFE_RELEASE(m_pobTexture); CC_SAFE_RELEASE(m_pobTexture);

View File

@ -152,11 +152,11 @@ namespace cocos2d
void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag) void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag)
{ {
assert(child != NULL); CCAssert(child != NULL, "child should not be null");
CCSprite *pSprite = (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()); CCAssert(pSprite->getTexture()->getName() == m_pobTextureAtlas->getTexture()->getName(), "");
CCNode::addChild(child, zOrder, tag); CCNode::addChild(child, zOrder, tag);
@ -177,8 +177,8 @@ namespace cocos2d
// override reorderChild // override reorderChild
void CCSpriteBatchNode::reorderChild(CCNode *child, int zOrder) void CCSpriteBatchNode::reorderChild(CCNode *child, int zOrder)
{ {
assert(child != NULL); CCAssert(child != NULL, "the child should not be null");
assert(m_pChildren->containsObject(child)); CCAssert(m_pChildren->containsObject(child), "sprite batch node should contain the child");
if (zOrder == child->getZOrder()) if (zOrder == child->getZOrder())
{ {
@ -203,7 +203,7 @@ namespace cocos2d
return; return;
} }
assert(m_pChildren->containsObject(pSprite)); CCAssert(m_pChildren->containsObject(pSprite), "sprite batch node should contain the child");
// cleanup before removing // cleanup before removing
removeSpriteFromAtlas(pSprite); removeSpriteFromAtlas(pSprite);
@ -307,7 +307,7 @@ namespace cocos2d
{ {
// serious problems // serious problems
CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); 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 // Should not happen. Error calculating Z on SpriteSheet
assert(0); CCAssert(0, "should not run here");
return 0; return 0;
} }

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCSpriteFrame.h" #include "CCSpriteFrame.h"
#include "CCDirector.h"
namespace cocos2d { namespace cocos2d {
// implementation of CCSpriteFrame // implementation of CCSpriteFrame

View File

@ -91,7 +91,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
} }
// check the format // check the format
assert(format >=0 && format <= 3); CCAssert(format >=0 && format <= 3, "");
framesDict->begin(); framesDict->begin();
std::string key = ""; std::string key = "";
@ -206,7 +206,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture
void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName) 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); CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(textureFileName);
if (texture) if (texture)

View File

@ -41,7 +41,7 @@ THE SOFTWARE.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include "ccMacros.h"
#include "CCObject.h" #include "CCObject.h"
#include "ccMacros.h" #include "ccMacros.h"

View File

@ -143,8 +143,8 @@ namespace cocos2d
int len; int len;
unsigned int offset = 0; unsigned int offset = 0;
assert( out ); CCAssert(out, "");
assert( &*out ); CCAssert(&*out, "");
gzFile inFile = gzopen(path, "rb"); gzFile inFile = gzopen(path, "rb");
if( inFile == NULL ) { if( inFile == NULL ) {
@ -210,8 +210,8 @@ namespace cocos2d
int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
{ {
assert( out ); CCAssert(out, "");
assert( &*out ); CCAssert(&*out, "");
// load file into memory // load file into memory
unsigned char *compressed = NULL; unsigned char *compressed = NULL;

View File

@ -41,6 +41,7 @@ THE SOFTWARE.
#include "support/ccUtils.h" #include "support/ccUtils.h"
#include "platform/CCPlatformMacros.h" #include "platform/CCPlatformMacros.h"
#include "CCTexturePVR.h" #include "CCTexturePVR.h"
#include "CCDirector.h"
#if CC_ENABLE_CACHE_TEXTTURE_DATA #if CC_ENABLE_CACHE_TEXTTURE_DATA
#include "CCTextureCache.h" #include "CCTextureCache.h"
@ -672,7 +673,7 @@ unsigned int CCTexture2D::bitsPerPixelForFormat()
break; break;
default: default:
ret = -1; ret = -1;
assert(false); CCAssert(false, "illegal pixel format");
CCLOG("bitsPerPixelForFormat: %d, cannot give useful result", m_ePixelFormat); CCLOG("bitsPerPixelForFormat: %d, cannot give useful result", m_ePixelFormat);
break; break;
} }

View File

@ -141,7 +141,7 @@ bool CCTextureAtlas::initWithFile(const char * file, unsigned int capacity)
bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, 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_uCapacity = capacity;
m_uTotalQuads = 0; m_uTotalQuads = 0;
@ -150,7 +150,7 @@ bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity
CC_SAFE_RETAIN(m_pTexture); CC_SAFE_RETAIN(m_pTexture);
// Re-initialization is not allowed // 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_pQuads = (ccV3F_C4B_T2F_Quad*)calloc( sizeof(ccV3F_C4B_T2F_Quad) * m_uCapacity, 1 );
m_pIndices = (GLushort *)calloc( sizeof(GLushort) * m_uCapacity * 6, 1 ); m_pIndices = (GLushort *)calloc( sizeof(GLushort) * m_uCapacity * 6, 1 );

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include "CCTextureCache.h" #include "CCTextureCache.h"
#include "CCPointExtension.h" #include "CCPointExtension.h"
#include "support/data_support/ccCArray.h" #include "support/data_support/ccCArray.h"
#include "CCDirector.h"
namespace cocos2d { namespace cocos2d {

View File

@ -183,7 +183,7 @@ namespace cocos2d{
if( gid != 0 ) if( gid != 0 )
{ {
// Optimization: quick return // 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 ) if( gid >= tileset->m_uFirstGid )
return tileset; return tileset;
} }

View File

@ -555,7 +555,7 @@ namespace cocos2d {
int sizeHint = (int)(s.width * s.height * sizeof(unsigned int)); int sizeHint = (int)(s.width * s.height * sizeof(unsigned int));
int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint); int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint);
assert(inflatedLen == sizeHint); CCAssert(inflatedLen == sizeHint, "");
inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warings in compiler inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warings in compiler

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
#include "CCTexture2D.h" #include "CCTexture2D.h"
#include "support/data_support/ccCArray.h" #include "support/data_support/ccCArray.h"
#include <assert.h>
#include <algorithm> #include <algorithm>
/** /**
@ -131,7 +130,7 @@ void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, CCMutableArray
if (h->getDelegate() == pHandler->getDelegate()) if (h->getDelegate() == pHandler->getDelegate())
{ {
assert(0); CCAssert(0, "");
return; return;
} }
} }
@ -269,13 +268,13 @@ void CCTouchDispatcher::rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArra
void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)
{ {
assert(pDelegate != NULL); CCAssert(pDelegate != NULL, "");
CCTouchHandler *handler = NULL; CCTouchHandler *handler = NULL;
handler = this->findHandler(pDelegate); handler = this->findHandler(pDelegate);
assert(handler != NULL); CCAssert(handler != NULL, "");
handler->setPriority(nPriority); handler->setPriority(nPriority);
@ -288,7 +287,7 @@ void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)
// //
void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int uIndex) void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int uIndex)
{ {
assert(uIndex >= 0 && uIndex < 4); CCAssert(uIndex >= 0 && uIndex < 4, "");
CCSet *pMutableTouches; CCSet *pMutableTouches;
m_bLocked = true; m_bLocked = true;

View File

@ -88,7 +88,7 @@ CCTouchHandler* CCTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate,
bool CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority) 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_pDelegate = pDelegate; pDelegate->keep();
m_nPriority = nPriority; m_nPriority = nPriority;