Merge pull request #3205 from dumganhar/ricardoquesada-property_synthesize_fixes

Merge PR https://github.com/cocos2d/cocos2d-x/pull/3202
This commit is contained in:
James Chen 2013-07-21 23:47:57 -07:00
commit 0d449cf828
133 changed files with 895 additions and 812 deletions

8
.gitmodules vendored
View File

@ -1,15 +1,15 @@
[submodule "tools/bindings-generator"]
path = tools/bindings-generator
url = https://github.com/cocos2d/bindings-generator.git
url = git://github.com/cocos2d/bindings-generator.git
[submodule "scripting/javascript/bindings/generated"]
path = scripting/javascript/bindings/generated
url = git://github.com/folecr/cocos2dx-autogen-bindings.git
[submodule "samples/Javascript/Shared"]
path = samples/Javascript/Shared
url = https://github.com/cocos2d/cocos2d-js-tests.git
url = git://github.com/cocos2d/cocos2d-js-tests.git
[submodule "external/emscripten"]
path = external/emscripten
url = https://github.com/kripken/emscripten.git
url = git://github.com/kripken/emscripten.git
[submodule "tools/cocos2d-console"]
path = tools/cocos2d-console
url = https://github.com/cocos2d/cocos2d-console.git
url = git://github.com/cocos2d/cocos2d-console.git

View File

@ -254,7 +254,7 @@ const char *Configuration::getCString( const char *key, const char *default_valu
if( String *str=dynamic_cast<String*>(ret) )
return str->getCString();
CCAssert(false, "Key found, but from different type");
CCASSERT(false, "Key found, but from different type");
}
// XXX: Should it throw an exception ?
@ -270,7 +270,7 @@ bool Configuration::getBool( const char *key, bool default_value ) const
return boolobj->getValue();
if( String *strobj=dynamic_cast<String*>(ret) )
return strobj->boolValue();
CCAssert(false, "Key found, but from different type");
CCASSERT(false, "Key found, but from different type");
}
// XXX: Should it throw an exception ?
@ -291,7 +291,7 @@ double Configuration::getNumber( const char *key, double default_value ) const
if( String *strobj=dynamic_cast<String*>(ret) )
return strobj->doubleValue();
CCAssert(false, "Key found, but from different type");
CCASSERT(false, "Key found, but from different type");
}
// XXX: Should it throw an exception ?
@ -315,7 +315,7 @@ void Configuration::setObject( const char *key, Object *value )
void Configuration::loadConfigFile( const char *filename )
{
Dictionary *dict = Dictionary::createWithContentsOfFile(filename);
CCAssert(dict, "cannot create dictionary");
CCASSERT(dict, "cannot create dictionary");
// search for metadata
bool metadata_ok = false;

View File

@ -216,7 +216,7 @@ void Director::setDefaultValues(void)
else if (strcmp(projection, "custom") == 0)
_projection = kDirectorProjectionCustom;
else
CCAssert(false, "Invalid projection value");
CCASSERT(false, "Invalid projection value");
// Default pixel format for PNG images with alpha
const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888");
@ -235,7 +235,7 @@ void Director::setDefaultValues(void)
void Director::setGLDefaultValues(void)
{
// This method SHOULD be called only after openGLView_ was initialized
CCAssert(_openGLView, "opengl view should not be null");
CCASSERT(_openGLView, "opengl view should not be null");
setAlphaBlending(true);
// XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did
@ -342,7 +342,7 @@ float Director::getDeltaTime() const
}
void Director::setOpenGLView(EGLView *pobOpenGLView)
{
CCAssert(pobOpenGLView, "opengl view should not be null");
CCASSERT(pobOpenGLView, "opengl view should not be null");
if (_openGLView != pobOpenGLView)
{
@ -576,8 +576,8 @@ Point Director::getVisibleOrigin() const
void Director::runWithScene(Scene *pScene)
{
CCAssert(pScene != NULL, "This command can only be used to start the Director. There is already a scene present.");
CCAssert(_runningScene == NULL, "_runningScene should be null");
CCASSERT(pScene != NULL, "This command can only be used to start the Director. There is already a scene present.");
CCASSERT(_runningScene == NULL, "_runningScene should be null");
pushScene(pScene);
startAnimation();
@ -585,8 +585,8 @@ void Director::runWithScene(Scene *pScene)
void Director::replaceScene(Scene *pScene)
{
CCAssert(_runningScene, "Use runWithScene: instead to start the director");
CCAssert(pScene != NULL, "the scene should not be null");
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
CCASSERT(pScene != NULL, "the scene should not be null");
unsigned int index = _scenesStack->count();
@ -598,7 +598,7 @@ void Director::replaceScene(Scene *pScene)
void Director::pushScene(Scene *pScene)
{
CCAssert(pScene, "the scene should not null");
CCASSERT(pScene, "the scene should not null");
_sendCleanupToScene = false;
@ -608,7 +608,7 @@ void Director::pushScene(Scene *pScene)
void Director::popScene(void)
{
CCAssert(_runningScene != NULL, "running scene should not null");
CCASSERT(_runningScene != NULL, "running scene should not null");
_scenesStack->removeLastObject();
unsigned int c = _scenesStack->count();
@ -631,7 +631,7 @@ void Director::popToRootScene(void)
void Director::popToSceneStackLevel(int level)
{
CCAssert(_runningScene != NULL, "A running Scene is needed");
CCASSERT(_runningScene != NULL, "A running Scene is needed");
int c = (int)_scenesStack->count();
// level 0? -> end

View File

@ -284,8 +284,8 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in
void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, unsigned int repeat, float delay, bool paused)
{
CCAssert(selector, "Argument selector must be non-NULL");
CCAssert(target, "Argument target must be non-NULL");
CCASSERT(selector, "Argument selector must be non-NULL");
CCASSERT(target, "Argument target must be non-NULL");
tHashTimerEntry *element = NULL;
HASH_FIND_INT(_hashForTimers, &target, element);
@ -305,7 +305,7 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in
}
else
{
CCAssert(element->paused == paused, "");
CCASSERT(element->paused == paused, "");
}
if (element->timers == NULL)
@ -342,8 +342,8 @@ void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target)
return;
}
//CCAssert(target);
//CCAssert(selector);
//CCASSERT(target);
//CCASSERT(selector);
tHashTimerEntry *element = NULL;
HASH_FIND_INT(_hashForTimers, &target, element);
@ -472,7 +472,7 @@ void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool pause
if (pHashElement)
{
#if COCOS2D_DEBUG >= 1
CCAssert(pHashElement->entry->markedForDeletion,"");
CCASSERT(pHashElement->entry->markedForDeletion,"");
#endif
// TODO: check if priority has changed!
@ -499,8 +499,8 @@ void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool pause
bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Object *target)
{
CCAssert(selector, "Argument selector must be non-NULL");
CCAssert(target, "Argument target must be non-NULL");
CCASSERT(selector, "Argument selector must be non-NULL");
CCASSERT(target, "Argument target must be non-NULL");
tHashTimerEntry *element = NULL;
HASH_FIND_INT(_hashForTimers, &target, element);
@ -692,7 +692,7 @@ void Scheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
void Scheduler::resumeTarget(Object *target)
{
CCAssert(target != NULL, "");
CCASSERT(target != NULL, "");
// custom selectors
tHashTimerEntry *element = NULL;
@ -707,14 +707,14 @@ void Scheduler::resumeTarget(Object *target)
HASH_FIND_INT(_hashForUpdates, &target, elementUpdate);
if (elementUpdate)
{
CCAssert(elementUpdate->entry != NULL, "");
CCASSERT(elementUpdate->entry != NULL, "");
elementUpdate->entry->paused = false;
}
}
void Scheduler::pauseTarget(Object *target)
{
CCAssert(target != NULL, "");
CCASSERT(target != NULL, "");
// custom selectors
tHashTimerEntry *element = NULL;
@ -729,14 +729,14 @@ void Scheduler::pauseTarget(Object *target)
HASH_FIND_INT(_hashForUpdates, &target, elementUpdate);
if (elementUpdate)
{
CCAssert(elementUpdate->entry != NULL, "");
CCASSERT(elementUpdate->entry != NULL, "");
elementUpdate->entry->paused = true;
}
}
bool Scheduler::isTargetPaused(Object *target)
{
CCAssert( target != NULL, "target must be non nil" );
CCASSERT( target != NULL, "target must be non nil" );
// Custom selectors
tHashTimerEntry *element = NULL;

View File

@ -106,7 +106,7 @@ Speed* Speed::create(ActionInterval* pAction, float fSpeed)
bool Speed::initWithAction(ActionInterval *pAction, float fSpeed)
{
CCAssert(pAction != NULL, "");
CCASSERT(pAction != NULL, "");
pAction->retain();
_innerAction = pAction;
_speed = fSpeed;
@ -196,7 +196,7 @@ Follow* Follow::reverse() const
bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = Rect::ZERO*/)
{
CCAssert(pFollowedNode != NULL, "");
CCASSERT(pFollowedNode != NULL, "");
pFollowedNode->retain();
_followedNode = pFollowedNode;

View File

@ -106,7 +106,7 @@ const std::vector<Point*>* PointArray::getControlPoints() const
void PointArray::setControlPoints(vector<Point*> *controlPoints)
{
CCAssert(controlPoints != NULL, "control points should not be NULL");
CCASSERT(controlPoints != NULL, "control points should not be NULL");
// delete old points
vector<Point*>::iterator iter;
@ -175,7 +175,7 @@ PointArray* PointArray::reverse() const
void PointArray::reverseInline()
{
unsigned int l = _controlPoints->size();
unsigned long l = _controlPoints->size();
Point *p1 = NULL;
Point *p2 = NULL;
int x, y;
@ -240,7 +240,7 @@ CardinalSplineTo* CardinalSplineTo::create(float duration, cocos2d::PointArray *
bool CardinalSplineTo::initWithDuration(float duration, cocos2d::PointArray *points, float tension)
{
CCAssert(points->count() > 0, "Invalid configuration. It must at least have one control point");
CCASSERT(points->count() > 0, "Invalid configuration. It must at least have one control point");
if (ActionInterval::initWithDuration(duration))
{

View File

@ -44,7 +44,7 @@ NS_CC_BEGIN
bool ActionEase::initWithAction(ActionInterval *pAction)
{
CCAssert(pAction != NULL, "");
CCASSERT(pAction != NULL, "");
if (ActionInterval::initWithDuration(pAction->getDuration()))
{
@ -663,7 +663,7 @@ void EaseElasticInOut::update(float time)
else
{
time = time * 2;
if (! _period)
if ( _period == 0)
{
_period = 0.3f * 1.5f;
}

View File

@ -59,7 +59,7 @@ void GridAction::startWithTarget(Node *target)
}
else
{
CCAssert(0, "");
CCASSERT(0, "");
}
}
else
@ -83,7 +83,7 @@ GridAction* GridAction::reverse() const
GridBase* GridAction::getGrid(void)
{
// Abstract class needs implementation
CCAssert(0, "");
CCASSERT(0, "");
return NULL;
}

View File

@ -117,7 +117,7 @@ bool FlipX3D::initWithSize(const Size& gridSize, float duration)
if (gridSize.width != 1 || gridSize.height != 1)
{
// Grid size must be (1,1)
CCAssert(0, "Grid size must be (1,1)");
CCASSERT(0, "Grid size must be (1,1)");
return false;
}

View File

@ -325,11 +325,11 @@ CallFunc * CallFunc::create(const std::function<void()> &func)
return NULL;
}
CallFunc * CallFunc::create(Object* pSelectorTarget, SEL_CallFunc selector)
CallFunc * CallFunc::create(Object* selectorTarget, SEL_CallFunc selector)
{
CallFunc *pRet = new CallFunc();
if (pRet && pRet->initWithTarget(pSelectorTarget)) {
if (pRet && pRet->initWithTarget(selectorTarget)) {
pRet->_callFunc = selector;
pRet->autorelease();
return pRet;
@ -345,10 +345,10 @@ bool CallFunc::initWithFunction(const std::function<void()> &func)
return true;
}
bool CallFunc::initWithTarget(Object* pSelectorTarget) {
if (pSelectorTarget)
bool CallFunc::initWithTarget(Object* selectorTarget) {
if (selectorTarget)
{
pSelectorTarget->retain();
selectorTarget->retain();
}
if (_selectorTarget)
@ -356,7 +356,7 @@ bool CallFunc::initWithTarget(Object* pSelectorTarget) {
_selectorTarget->release();
}
_selectorTarget = pSelectorTarget;
_selectorTarget = selectorTarget;
return true;
}
@ -418,11 +418,11 @@ CallFuncN * CallFuncN::create(const std::function<void(Node*)> &func)
}
// XXX deprecated
CallFuncN * CallFuncN::create(Object* pSelectorTarget, SEL_CallFuncN selector)
CallFuncN * CallFuncN::create(Object* selectorTarget, SEL_CallFuncN selector)
{
CallFuncN *pRet = new CallFuncN();
if (pRet && pRet->initWithTarget(pSelectorTarget, selector))
if (pRet && pRet->initWithTarget(selectorTarget, selector))
{
pRet->autorelease();
return pRet;
@ -447,9 +447,9 @@ bool CallFuncN::initWithFunction(const std::function<void (Node *)> &func)
return true;
}
bool CallFuncN::initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector)
bool CallFuncN::initWithTarget(Object* selectorTarget, SEL_CallFuncN selector)
{
if (CallFunc::initWithTarget(pSelectorTarget)) {
if (CallFunc::initWithTarget(selectorTarget)) {
_callFuncN = selector;
return true;
}

View File

@ -127,13 +127,13 @@ void ActionInterval::setAmplitudeRate(float amp)
{
CC_UNUSED_PARAM(amp);
// Abstract class needs implementation
CCAssert(0, "");
CCASSERT(0, "");
}
float ActionInterval::getAmplitudeRate(void)
{
// Abstract class needs implementation
CCAssert(0, "");
CCASSERT(0, "");
return 0;
}
@ -227,8 +227,8 @@ Sequence* Sequence::create(Array* arrayOfActions)
bool Sequence::initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo)
{
CCAssert(pActionOne != NULL, "");
CCAssert(pActionTwo != NULL, "");
CCASSERT(pActionOne != NULL, "");
CCASSERT(pActionTwo != NULL, "");
float d = pActionOne->getDuration() + pActionTwo->getDuration();
ActionInterval::initWithDuration(d);
@ -483,7 +483,7 @@ RepeatForever *RepeatForever::create(ActionInterval *pAction)
bool RepeatForever::initWithAction(ActionInterval *pAction)
{
CCAssert(pAction != NULL, "");
CCASSERT(pAction != NULL, "");
pAction->retain();
_innerAction = pAction;
return true;
@ -608,8 +608,8 @@ Spawn* Spawn::createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction
bool Spawn:: initWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2)
{
CCAssert(pAction1 != NULL, "");
CCAssert(pAction2 != NULL, "");
CCASSERT(pAction1 != NULL, "");
CCASSERT(pAction2 != NULL, "");
bool bRet = false;
@ -802,7 +802,7 @@ void RotateTo::update(float time)
RotateTo *RotateTo::reverse() const
{
CCAssert(false, "RotateTo doesn't support the 'reverse' method");
CCASSERT(false, "RotateTo doesn't support the 'reverse' method");
return nullptr;
}
@ -1031,7 +1031,7 @@ SkewTo* SkewTo::clone(void) const
SkewTo* SkewTo::reverse() const
{
CCAssert(false, "reverse() not supported in SkewTo");
CCASSERT(false, "reverse() not supported in SkewTo");
return nullptr;
}
@ -1165,7 +1165,7 @@ SkewBy* SkewBy::reverse() const
// JumpBy
//
JumpBy* JumpBy::create(float duration, const Point& position, float height, unsigned int jumps)
JumpBy* JumpBy::create(float duration, const Point& position, float height, int jumps)
{
JumpBy *pJumpBy = new JumpBy();
pJumpBy->initWithDuration(duration, position, height, jumps);
@ -1174,9 +1174,11 @@ JumpBy* JumpBy::create(float duration, const Point& position, float height, unsi
return pJumpBy;
}
bool JumpBy::initWithDuration(float duration, const Point& position, float height, unsigned int jumps)
bool JumpBy::initWithDuration(float duration, const Point& position, float height, int jumps)
{
if (ActionInterval::initWithDuration(duration))
CCASSERT(jumps>=0, "Number of jumps must be >= 0");
if (ActionInterval::initWithDuration(duration) && jumps>=0)
{
_delta = position;
_height = height;
@ -1259,7 +1261,7 @@ JumpTo* JumpTo::clone(void) const
JumpTo* JumpTo::reverse() const
{
CCAssert(false, "reverse() not supported in JumpTo");
CCASSERT(false, "reverse() not supported in JumpTo");
return nullptr;
}
@ -1407,7 +1409,7 @@ void BezierTo::startWithTarget(Node *target)
BezierTo* BezierTo::reverse() const
{
CCAssert(false, "CCBezierTo doesn't support the 'reverse' method");
CCASSERT(false, "CCBezierTo doesn't support the 'reverse' method");
return nullptr;
}
@ -1470,7 +1472,7 @@ ScaleTo* ScaleTo::clone(void) const
ScaleTo* ScaleTo::reverse() const
{
CCAssert(false, "reverse() not supported in ScaleTo");
CCASSERT(false, "reverse() not supported in ScaleTo");
return nullptr;
}
@ -1540,20 +1542,22 @@ ScaleBy* ScaleBy::reverse() const
// Blink
//
Blink* Blink::create(float duration, unsigned int uBlinks)
Blink* Blink::create(float duration, int blinks)
{
Blink *pBlink = new Blink();
pBlink->initWithDuration(duration, uBlinks);
pBlink->initWithDuration(duration, blinks);
pBlink->autorelease();
return pBlink;
}
bool Blink::initWithDuration(float duration, unsigned int uBlinks)
bool Blink::initWithDuration(float duration, int blinks)
{
if (ActionInterval::initWithDuration(duration))
CCASSERT(blinks>=0, "blinks should be >= 0");
if (ActionInterval::initWithDuration(duration) && blinks>=0)
{
_times = uBlinks;
_times = blinks;
return true;
}
@ -1576,7 +1580,7 @@ Blink* Blink::clone(void) const
{
// no copy constructor
auto a = new Blink();
a->initWithDuration(_duration, (unsigned int)_times);
a->initWithDuration(_duration, _times);
a->autorelease();
return a;
}
@ -1707,7 +1711,7 @@ FadeTo* FadeTo::clone() const
FadeTo* FadeTo::reverse() const
{
CCAssert(false, "reverse() not supported in FadeTo");
CCASSERT(false, "reverse() not supported in FadeTo");
return nullptr;
}
@ -1767,7 +1771,7 @@ TintTo* TintTo::clone() const
TintTo* TintTo::reverse() const
{
CCAssert(false, "reverse() not supported in TintTo");
CCASSERT(false, "reverse() not supported in TintTo");
return nullptr;
}
@ -1788,8 +1792,8 @@ void TintTo::update(float time)
if (pRGBAProtocol)
{
pRGBAProtocol->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time),
(GLbyte)(_from.g + (_to.g - _from.g) * time),
(GLbyte)(_from.b + (_to.b - _from.b) * time)));
(GLubyte)(_from.g + (_to.g - _from.g) * time),
(GLubyte)(_from.b + (_to.b - _from.b) * time)));
}
}
@ -1908,8 +1912,8 @@ ReverseTime* ReverseTime::create(FiniteTimeAction *pAction)
bool ReverseTime::initWithAction(FiniteTimeAction *pAction)
{
CCAssert(pAction != NULL, "");
CCAssert(pAction != _other, "");
CCASSERT(pAction != NULL, "");
CCASSERT(pAction != _other, "");
if (ActionInterval::initWithDuration(pAction->getDuration()))
{
@ -1982,9 +1986,26 @@ Animate* Animate::create(Animation *pAnimation)
return pAnimate;
}
Animate::Animate()
: _animation(NULL)
, _splitTimes(new std::vector<float>)
, _nextFrame(0)
, _origFrame(NULL)
, _executedLoops(0)
{
}
Animate::~Animate()
{
CC_SAFE_RELEASE(_animation);
CC_SAFE_RELEASE(_origFrame);
CC_SAFE_DELETE(_splitTimes);
}
bool Animate::initWithAnimation(Animation *pAnimation)
{
CCAssert( pAnimation!=NULL, "Animate: argument Animation must be non-NULL");
CCASSERT( pAnimation!=NULL, "Animate: argument Animation must be non-NULL");
float singleDuration = pAnimation->getDuration();
@ -2016,6 +2037,16 @@ bool Animate::initWithAnimation(Animation *pAnimation)
return false;
}
void Animate::setAnimation(cocos2d::Animation *animation)
{
if (_animation != animation)
{
CC_SAFE_RETAIN(animation);
CC_SAFE_RELEASE(_animation);
_animation = animation;
}
}
Animate* Animate::clone() const
{
// no copy constructor
@ -2025,23 +2056,6 @@ Animate* Animate::clone() const
return a;
}
Animate::Animate()
: _animation(NULL)
, _splitTimes(new std::vector<float>)
, _nextFrame(0)
, _origFrame(NULL)
, _executedLoops(0)
{
}
Animate::~Animate()
{
CC_SAFE_RELEASE(_animation);
CC_SAFE_RELEASE(_origFrame);
CC_SAFE_DELETE(_splitTimes);
}
void Animate::startWithTarget(Node *target)
{
ActionInterval::startWithTarget(target);
@ -2089,7 +2103,7 @@ void Animate::update(float t)
unsigned int numberOfFrames = frames->count();
SpriteFrame *frameToDisplay = NULL;
for( unsigned int i=_nextFrame; i < numberOfFrames; i++ ) {
for( int i=_nextFrame; i < numberOfFrames; i++ ) {
float splitTime = _splitTimes->at(i);
if( splitTime <= t ) {
@ -2207,4 +2221,13 @@ void TargetedAction::update(float time)
_action->update(time);
}
void TargetedAction::setForcedTarget(Node* forcedTarget)
{
if( _forcedTarget != forcedTarget ) {
CC_SAFE_RETAIN(forcedTarget);
CC_SAFE_RELEASE(_forcedTarget);
_forcedTarget = forcedTarget;
}
}
NS_CC_END

View File

@ -424,10 +424,10 @@ class CC_DLL JumpBy : public ActionInterval
{
public:
/** creates the action */
static JumpBy* create(float duration, const Point& position, float height, unsigned int jumps);
static JumpBy* create(float duration, const Point& position, float height, int jumps);
/** initializes the action */
bool initWithDuration(float duration, const Point& position, float height, unsigned int jumps);
bool initWithDuration(float duration, const Point& position, float height, int jumps);
//
// Overrides
@ -441,7 +441,7 @@ protected:
Point _startPosition;
Point _delta;
float _height;
unsigned int _jumps;
int _jumps;
Point _previousPos;
};
@ -580,10 +580,10 @@ class CC_DLL Blink : public ActionInterval
{
public:
/** creates the action */
static Blink* create(float duration, unsigned int uBlinks);
static Blink* create(float duration, int blinks);
/** initializes the action */
bool initWithDuration(float duration, unsigned int uBlinks);
bool initWithDuration(float duration, int blinks);
//
// Overrides
@ -595,7 +595,7 @@ public:
virtual void stop() override;
protected:
unsigned int _times;
int _times;
bool _originalState;
};
@ -776,6 +776,12 @@ public:
/** initializes the action with an Animation and will restore the original frame when the animation is over */
bool initWithAnimation(Animation *pAnimation);
/** sets the Animation object to be animated */
void setAnimation( Animation* animation );
/** returns the Animation object that is being animated */
Animation* getAnimation() { return _animation; }
const Animation* getAnimation() const { return _animation; }
//
// Overrides
//
@ -785,14 +791,12 @@ public:
virtual void stop(void) override;
virtual void update(float t) override;
public:
CC_SYNTHESIZE_RETAIN(Animation*, _animation, Animation)
protected:
std::vector<float>* _splitTimes;
int _nextFrame;
SpriteFrame* _origFrame;
int _nextFrame;
SpriteFrame* _origFrame;
unsigned int _executedLoops;
Animation* _animation;
};
/** Overrides the target of an action so that it always runs on the target
@ -810,6 +814,12 @@ public:
/** Init an action with the specified action and forced target */
bool initWithTarget(Node* target, FiniteTimeAction* pAction);
/** Sets the target that the action will be forced to run with */
void setForcedTarget(Node* forcedTarget);
/** returns the target that the action is forced to run with */
Node* getForcedTarget() { return _forcedTarget; }
const Node* getForcedTarget() const { return _forcedTarget; }
//
// Overrides
//
@ -819,11 +829,9 @@ public:
virtual void stop(void) override;
virtual void update(float time) override;
public:
/** This is the target that the action will be forced to run with */
CC_SYNTHESIZE_RETAIN(Node*, _forcedTarget, ForcedTarget);
private:
FiniteTimeAction* _action;
Node* _forcedTarget;
};
// end of actions group

View File

@ -170,8 +170,8 @@ void ActionManager::resumeTargets(cocos2d::Set *targetsToResume)
void ActionManager::addAction(Action *pAction, Node *target, bool paused)
{
CCAssert(pAction != NULL, "");
CCAssert(target != NULL, "");
CCASSERT(pAction != NULL, "");
CCASSERT(target != NULL, "");
tHashElement *pElement = NULL;
// we should convert it to Object*, because we save it as Object*
@ -188,7 +188,7 @@ void ActionManager::addAction(Action *pAction, Node *target, bool paused)
actionAllocWithHashElement(pElement);
CCAssert(! ccArrayContainsObject(pElement->actions, pAction), "");
CCASSERT(! ccArrayContainsObject(pElement->actions, pAction), "");
ccArrayAppendObject(pElement->actions, pAction);
pAction->startWithTarget(target);
@ -267,8 +267,8 @@ void ActionManager::removeAction(Action *pAction)
void ActionManager::removeActionByTag(unsigned int tag, Object *target)
{
CCAssert((int)tag != kActionTagInvalid, "");
CCAssert(target != NULL, "");
CCASSERT((int)tag != kActionTagInvalid, "");
CCASSERT(target != NULL, "");
tHashElement *pElement = NULL;
HASH_FIND_INT(_targets, &target, pElement);
@ -295,7 +295,7 @@ void ActionManager::removeActionByTag(unsigned int tag, Object *target)
// and, it is not possible to get the address of a reference
Action* ActionManager::getActionByTag(unsigned int tag, const Object *target) const
{
CCAssert((int)tag != kActionTagInvalid, "");
CCASSERT((int)tag != kActionTagInvalid, "");
tHashElement *pElement = NULL;
HASH_FIND_INT(_targets, &target, pElement);

View File

@ -63,7 +63,7 @@ ProgressTo* ProgressTo::clone() const
ProgressTo* ProgressTo::reverse() const
{
CCAssert(false, "reverse() not supported in ProgressTo");
CCASSERT(false, "reverse() not supported in ProgressTo");
return nullptr;
}

View File

@ -65,7 +65,7 @@ ActionTween *ActionTween::clone() const
void ActionTween::startWithTarget(Node *target)
{
CCAssert(dynamic_cast<ActionTweenDelegate*>(target), "target must implement ActionTweenDelegate");
CCASSERT(dynamic_cast<ActionTweenDelegate*>(target), "target must implement ActionTweenDelegate");
ActionInterval::startWithTarget(target);
_delta = _to - _from;
}

View File

@ -76,7 +76,7 @@ AtlasNode * AtlasNode::create(const char *tile, unsigned int tileWidth, unsigned
bool AtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender)
{
CCAssert(tile != NULL, "title should not be null");
CCASSERT(tile != NULL, "title should not be null");
Texture2D *texture = TextureCache::getInstance()->addImage(tile);
return initWithTexture(texture, tileWidth, tileHeight, itemsToRender);
}
@ -134,7 +134,7 @@ void AtlasNode::calculateMaxItems()
void AtlasNode::updateAtlasValues()
{
CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overridden");
CCASSERT(false, "CCAtlasNode:Abstract updateAtlasValue not overridden");
}
// AtlasNode - draw

View File

@ -208,7 +208,7 @@ void Node::setVertexZ(float var)
/// rotation getter
float Node::getRotation() const
{
CCAssert(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return");
CCASSERT(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return");
return _rotationX;
}
@ -244,7 +244,7 @@ void Node::setRotationY(float fRotationY)
/// scale getter
float Node::getScale(void) const
{
CCAssert( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return");
CCASSERT( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return");
return _scaleX;
}
@ -445,14 +445,15 @@ void Node::setUserData(void *var)
_userData = var;
}
unsigned int Node::getOrderOfArrival() const
int Node::getOrderOfArrival() const
{
return _orderOfArrival;
}
void Node::setOrderOfArrival(unsigned int uOrderOfArrival)
void Node::setOrderOfArrival(int orderOfArrival)
{
_orderOfArrival = uOrderOfArrival;
CCASSERT(orderOfArrival >=0, "Invalid orderOfArrival");
_orderOfArrival = orderOfArrival;
}
ccGLServerState Node::getGLServerState() const
@ -536,7 +537,7 @@ void Node::childrenAlloc(void)
Node* Node::getChildByTag(int aTag)
{
CCAssert( aTag != kNodeTagInvalid, "Invalid tag");
CCASSERT( aTag != kNodeTagInvalid, "Invalid tag");
if(_children && _children->count() > 0)
{
@ -557,8 +558,8 @@ Node* Node::getChildByTag(int aTag)
*/
void Node::addChild(Node *child, int zOrder, int tag)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCAssert( child->_parent == NULL, "child already added. It can't be added again");
CCASSERT( child != NULL, "Argument must be non-nil");
CCASSERT( child->_parent == NULL, "child already added. It can't be added again");
if( ! _children )
{
@ -584,13 +585,13 @@ void Node::addChild(Node *child, int zOrder, int tag)
void Node::addChild(Node *child, int zOrder)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCASSERT( child != NULL, "Argument must be non-nil");
this->addChild(child, zOrder, child->_tag);
}
void Node::addChild(Node *child)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCASSERT( child != NULL, "Argument must be non-nil");
this->addChild(child, child->_ZOrder, child->_tag);
}
@ -627,7 +628,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
void Node::removeChildByTag(int tag, bool cleanup/* = true */)
{
CCAssert( tag != kNodeTagInvalid, "Invalid tag");
CCASSERT( tag != kNodeTagInvalid, "Invalid tag");
Node *child = this->getChildByTag(tag);
@ -715,7 +716,7 @@ void Node::insertChild(Node* child, int z)
void Node::reorderChild(Node *child, int zOrder)
{
CCAssert( child != NULL, "Child must be non-nil");
CCASSERT( child != NULL, "Child must be non-nil");
_reorderChildDirty = true;
child->setOrderOfArrival(s_globalOrderOfArrival++);
child->_setZOrder(zOrder);
@ -753,7 +754,7 @@ void Node::sortAllChildren()
void Node::draw()
{
//CCAssert(0);
//CCASSERT(0);
// override me
// Only use- this function to draw your stuff.
// DON'T draw your stuff outside this method
@ -953,7 +954,7 @@ void Node::setActionManager(ActionManager* actionManager)
Action * Node::runAction(Action* action)
{
CCAssert( action != NULL, "Argument must be non-nil");
CCASSERT( action != NULL, "Argument must be non-nil");
_actionManager->addAction(action, this, !_running);
return action;
}
@ -970,13 +971,13 @@ void Node::stopAction(Action* action)
void Node::stopActionByTag(int tag)
{
CCAssert( tag != kActionTagInvalid, "Invalid tag");
CCASSERT( tag != kActionTagInvalid, "Invalid tag");
_actionManager->removeActionByTag(tag, this);
}
Action * Node::getActionByTag(int tag)
{
CCAssert( tag != kActionTagInvalid, "Invalid tag");
CCASSERT( tag != kActionTagInvalid, "Invalid tag");
return _actionManager->getActionByTag(tag, this);
}
@ -1041,8 +1042,8 @@ void Node::schedule(SEL_SCHEDULE selector, float interval)
void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
{
CCAssert( selector, "Argument must be non-nil");
CCAssert( interval >=0, "Argument must be positive");
CCASSERT( selector, "Argument must be non-nil");
CCASSERT( interval >=0, "Argument must be positive");
_scheduler->scheduleSelector(selector, this, interval , repeat, delay, !_running);
}

View File

@ -502,9 +502,9 @@ public:
*
* @warning This method is used internally for zOrder sorting, don't change this manually
*
* @param uOrderOfArrival The arrival order.
* @param orderOfArrival The arrival order.
*/
virtual void setOrderOfArrival(unsigned int orderOfArrival);
virtual void setOrderOfArrival(int orderOfArrival);
/**
* Returns the arrival order, indecates which children is added previously.
*
@ -512,7 +512,7 @@ public:
*
* @return The arrival order.
*/
virtual unsigned int getOrderOfArrival() const;
virtual int getOrderOfArrival() const;
/**
@ -1362,7 +1362,7 @@ protected:
ccGLServerState _GLServerState; ///< OpenGL servier side state
unsigned int _orderOfArrival; ///< used to preserve sequence while sorting children with the same zOrder
int _orderOfArrival; ///< used to preserve sequence while sorting children with the same zOrder
Scheduler *_scheduler; ///< scheduler used to schedule timers and updates

View File

@ -94,13 +94,13 @@ AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float s
AffineTransform AffineTransformRotate(const AffineTransform& t, float anAngle)
{
float fSin = sin(anAngle);
float fCos = cos(anAngle);
float sine = sinf(anAngle);
float cosine = cosf(anAngle);
return __CCAffineTransformMake( t.a * fCos + t.c * fSin,
t.b * fCos + t.d * fSin,
t.c * fCos - t.a * fSin,
t.d * fCos - t.b * fSin,
return __CCAffineTransformMake( t.a * cosine + t.c * sine,
t.b * cosine + t.d * sine,
t.c * cosine - t.a * sine,
t.d * cosine - t.b * sine,
t.tx,
t.ty);
}

View File

@ -221,7 +221,7 @@ unsigned int Array::indexOfObject(Object* object) const
Object* Array::objectAtIndex(unsigned int index)
{
CCAssert(index < data->num, "index out of range in objectAtIndex()");
CCASSERT(index < data->num, "index out of range in objectAtIndex()");
return data->arr[index];
}
@ -285,7 +285,7 @@ void Array::insertObject(Object* object, unsigned int index)
void Array::removeLastObject(bool bReleaseObj)
{
CCAssert(data->num, "no objects added");
CCASSERT(data->num, "no objects added");
ccArrayRemoveObjectAtIndex(data, data->num-1, bReleaseObj);
}

View File

@ -66,7 +66,7 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0
if ((__array__) && (__array__)->data->num > 0) \
for(Object** __arr__ = (__array__)->data->arr, \
**__end__ = (__array__)->data->arr + (__array__)->data->num-1; __arr__ <= __end__; __arr__++) \
CCAssert(dynamic_cast<__type__>(*__arr__), "element type is wrong!"); \
CCASSERT(dynamic_cast<__type__>(*__arr__), "element type is wrong!"); \
} while(false)
#else
#define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0)

View File

@ -43,7 +43,7 @@ void AutoreleasePool::addObject(Object* pObject)
{
_managedObjectArray->addObject(pObject);
CCAssert(pObject->_reference > 1, "reference count should be greater than 1");
CCASSERT(pObject->_reference > 1, "reference count should be greater than 1");
++(pObject->_autoReleaseCount);
pObject->release(); // no ref count, in this case autorelease pool added.
}
@ -177,7 +177,7 @@ void PoolManager::pop()
void PoolManager::removeObject(Object* pObject)
{
CCAssert(_curReleasePool, "current auto release pool should not be null");
CCASSERT(_curReleasePool, "current auto release pool should not be null");
_curReleasePool->removeObject(pObject);
}
@ -195,7 +195,7 @@ AutoreleasePool* PoolManager::getCurReleasePool()
push();
}
CCAssert(_curReleasePool, "current auto release pool should not be null");
CCASSERT(_curReleasePool, "current auto release pool should not be null");
return _curReleasePool;
}

View File

@ -36,11 +36,11 @@ NS_CC_BEGIN
DictElement::DictElement(const char* pszKey, Object* pObject)
{
CCAssert(pszKey && strlen(pszKey) > 0, "Invalid key value.");
CCASSERT(pszKey && strlen(pszKey) > 0, "Invalid key value.");
_intKey = 0;
const char* pStart = pszKey;
int len = strlen(pszKey);
size_t len = strlen(pszKey);
if (len > MAX_KEY_LEN )
{
char* pEnd = (char*)&pszKey[len-1];
@ -157,7 +157,7 @@ Object* Dictionary::objectForKey(const std::string& key)
if (_dictType == kDictUnknown) return NULL;
// Dictionary only supports one kind of key, string or integer.
// This method uses string as key, therefore we should make sure that the key type of this Dictionary is string.
CCAssert(_dictType == kDictStr, "this dictionary does not use string as key.");
CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key.");
Object* pRetObject = NULL;
DictElement *pElement = NULL;
@ -175,7 +175,7 @@ Object* Dictionary::objectForKey(intptr_t key)
if (_dictType == kDictUnknown) return NULL;
// Dictionary only supports one kind of key, string or integer.
// This method uses integer as key, therefore we should make sure that the key type of this Dictionary is integer.
CCAssert(_dictType == kDictInt, "this dictionary does not use integer as key.");
CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key.");
Object* pRetObject = NULL;
DictElement *pElement = NULL;
@ -209,13 +209,13 @@ const String* Dictionary::valueForKey(intptr_t key)
void Dictionary::setObject(Object* pObject, const std::string& key)
{
CCAssert(key.length() > 0 && pObject != NULL, "Invalid Argument!");
CCASSERT(key.length() > 0 && pObject != NULL, "Invalid Argument!");
if (_dictType == kDictUnknown)
{
_dictType = kDictStr;
}
CCAssert(_dictType == kDictStr, "this dictionary doesn't use string as key.");
CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as key.");
DictElement *pElement = NULL;
HASH_FIND_STR(_elements, key.c_str(), pElement);
@ -235,13 +235,13 @@ void Dictionary::setObject(Object* pObject, const std::string& key)
void Dictionary::setObject(Object* pObject, intptr_t key)
{
CCAssert(pObject != NULL, "Invalid Argument!");
CCASSERT(pObject != NULL, "Invalid Argument!");
if (_dictType == kDictUnknown)
{
_dictType = kDictInt;
}
CCAssert(_dictType == kDictInt, "this dictionary doesn't use integer as key.");
CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as key.");
DictElement *pElement = NULL;
HASH_FIND_PTR(_elements, &key, pElement);
@ -267,8 +267,8 @@ void Dictionary::removeObjectForKey(const std::string& key)
return;
}
CCAssert(_dictType == kDictStr, "this dictionary doesn't use string as its key");
CCAssert(key.length() > 0, "Invalid Argument!");
CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as its key");
CCASSERT(key.length() > 0, "Invalid Argument!");
DictElement *pElement = NULL;
HASH_FIND_STR(_elements, key.c_str(), pElement);
removeObjectForElememt(pElement);
@ -281,7 +281,7 @@ void Dictionary::removeObjectForKey(intptr_t key)
return;
}
CCAssert(_dictType == kDictInt, "this dictionary doesn't use integer as its key");
CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as its key");
DictElement *pElement = NULL;
HASH_FIND_PTR(_elements, &key, pElement);
removeObjectForElememt(pElement);

View File

@ -95,7 +95,7 @@ public:
*/
inline const char* getStrKey() const
{
CCAssert(_strKey[0] != '\0', "Should not call this function for integer dictionary");
CCASSERT(_strKey[0] != '\0', "Should not call this function for integer dictionary");
return _strKey;
}
@ -108,7 +108,7 @@ public:
*/
inline intptr_t getIntKey() const
{
CCAssert(_strKey[0] == '\0', "Should not call this function for string dictionary");
CCASSERT(_strKey[0] == '\0', "Should not call this function for string dictionary");
return _intKey;
}

View File

@ -32,7 +32,7 @@ Point::Point(void) : x(0), y(0)
{
}
Point::Point(float x, float y) : x(x), y(y)
Point::Point(float xx, float yy) : x(xx), y(yy)
{
}
@ -78,14 +78,14 @@ Point Point::operator*(float a) const
Point Point::operator/(float a) const
{
CCAssert(a, "CCPoint division by 0.");
CCASSERT(a!=0, "CCPoint division by 0.");
return Point(this->x / a, this->y / a);
}
void Point::setPoint(float x, float y)
void Point::setPoint(float xx, float yy)
{
this->x = x;
this->y = y;
this->x = xx;
this->y = yy;
}
bool Point::equals(const Point& target) const
@ -196,7 +196,7 @@ Size::Size(void) : width(0), height(0)
{
}
Size::Size(float width, float height) : width(width), height(height)
Size::Size(float w, float h) : width(w), height(h)
{
}
@ -237,14 +237,14 @@ Size Size::operator*(float a) const
Size Size::operator/(float a) const
{
CCAssert(a, "CCSize division by 0.");
CCASSERT(a!=0, "CCSize division by 0.");
return Size(this->width / a, this->height / a);
}
void Size::setSize(float width, float height)
void Size::setSize(float w, float h)
{
this->width = width;
this->height = height;
this->width = w;
this->height = h;
}
bool Size::equals(const Size& target) const
@ -281,7 +281,7 @@ Rect& Rect::operator= (const Rect& other)
void Rect::setRect(float x, float y, float width, float height)
{
// CGRect can support width<0 or height<0
// CCAssert(width >= 0.0f && height >= 0.0f, "width and height of Rect must not less than 0.");
// CCASSERT(width >= 0.0f && height >= 0.0f, "width and height of Rect must not less than 0.");
origin.x = x;
origin.y = y;

View File

@ -66,7 +66,7 @@ Object::~Object(void)
void Object::release(void)
{
CCAssert(_reference > 0, "reference count should greater than 0");
CCASSERT(_reference > 0, "reference count should greater than 0");
--_reference;
if (_reference == 0)
@ -77,7 +77,7 @@ void Object::release(void)
void Object::retain(void)
{
CCAssert(_reference > 0, "reference count should greater than 0");
CCASSERT(_reference > 0, "reference count should greater than 0");
++_reference;
}

View File

@ -141,8 +141,10 @@ DrawNode* DrawNode::create()
return pRet;
}
void DrawNode::ensureCapacity(unsigned int count)
void DrawNode::ensureCapacity(int count)
{
CCASSERT(count>=0, "capacity must be >= 0");
if(_bufferCount + count > _bufferCapacity)
{
_bufferCapacity += MAX(_bufferCapacity, count);

View File

@ -73,22 +73,20 @@ public:
// Overrides
virtual void draw() override;
private:
void ensureCapacity(unsigned int count);
protected:
void ensureCapacity(int count);
void render();
protected:
GLuint _vao;
GLuint _vbo;
unsigned int _bufferCapacity;
GLsizei _bufferCount;
V2F_C4B_T2F *_buffer;
int _bufferCapacity;
GLsizei _bufferCount;
V2F_C4B_T2F *_buffer;
BlendFunc _blendFunc;
bool _dirty;
BlendFunc _blendFunc;
bool _dirty;
};
NS_CC_END

View File

@ -53,7 +53,7 @@ void Grabber::grab(Texture2D *pTexture)
GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
CCAssert(0, "Frame Grabber: could not attach texture to framebuffer");
CCASSERT(0, "Frame Grabber: could not attach texture to framebuffer");
}
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);

View File

@ -238,17 +238,17 @@ void GridBase::afterDraw(cocos2d::Node *target)
void GridBase::blit(void)
{
CCAssert(0, "");
CCASSERT(0, "");
}
void GridBase::reuse(void)
{
CCAssert(0, "");
CCASSERT(0, "");
}
void GridBase::calculateVertexPoints(void)
{
CCAssert(0, "");
CCASSERT(0, "");
}
// implementation of Grid3D
@ -426,7 +426,7 @@ void Grid3D::calculateVertexPoints(void)
Vertex3F Grid3D::getVertex(const Point& pos) const
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_vertices;
@ -438,7 +438,7 @@ Vertex3F Grid3D::getVertex(const Point& pos) const
Vertex3F Grid3D::getOriginalVertex(const Point& pos) const
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_originalVertices;
@ -450,7 +450,7 @@ Vertex3F Grid3D::getOriginalVertex(const Point& pos) const
void Grid3D::setVertex(const Point& pos, const Vertex3F& vertex)
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
float *vertArray = (float*)_vertices;
vertArray[index] = vertex.x;
@ -646,7 +646,7 @@ void TiledGrid3D::calculateVertexPoints(void)
void TiledGrid3D::setTile(const Point& pos, const Quad3& coords)
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_vertices;
memcpy(&vertArray[idx], &coords, sizeof(Quad3));
@ -654,7 +654,7 @@ void TiledGrid3D::setTile(const Point& pos, const Quad3& coords)
Quad3 TiledGrid3D::getOriginalTile(const Point& pos) const
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_originalVertices;
@ -666,7 +666,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Point& pos) const
Quad3 TiledGrid3D::getTile(const Point& pos) const
{
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_vertices;

View File

@ -34,10 +34,10 @@ THE SOFTWARE.
#include "platform/CCCommon.h"
#include "CCStdC.h"
#ifndef CCAssert
#ifndef CCASSERT
#if COCOS2D_DEBUG > 0
extern bool CC_DLL cc_assert_script_compatible(const char *msg);
#define CCAssert(cond, msg) do { \
#define CCASSERT(cond, msg) do { \
if (!(cond)) { \
if (!cc_assert_script_compatible(msg) && strlen(msg)) \
cocos2d::CCLog("Assert failed: %s", msg); \
@ -45,9 +45,11 @@ extern bool CC_DLL cc_assert_script_compatible(const char *msg);
} \
} while (0)
#else
#define CCAssert(cond, msg)
#define CCASSERT(cond, msg)
#endif
#endif // CCAssert
// XXX: Backward compatible
#define CCAssert CCASSERT
#endif // CCASSERT
#include "ccConfig.h"
@ -96,7 +98,7 @@ default gl blend src function. Compatible with premultiplied alpha images.
#define CC_NODE_DRAW_SETUP() \
do { \
ccGLEnable(_GLServerState); \
CCAssert(getShaderProgram(), "No shader program set for this node"); \
CCASSERT(getShaderProgram(), "No shader program set for this node"); \
{ \
getShaderProgram()->use(); \
getShaderProgram()->setUniformsForBuiltins(); \

View File

@ -41,7 +41,7 @@ public:
static inline unsigned int getHashCodeByString(const char *key)
{
unsigned int len = strlen(key);
size_t len = strlen(key);
const char *end=key+len;
unsigned int hash;

View File

@ -61,7 +61,7 @@ void KeypadHandler::setDelegate(KeypadDelegate *pDelegate)
bool KeypadHandler::initWithDelegate(KeypadDelegate *pDelegate)
{
CCAssert(pDelegate != NULL, "It's a wrong delegate!");
CCASSERT(pDelegate != NULL, "It's a wrong delegate!");
_delegate = pDelegate;
dynamic_cast<Object*>(pDelegate)->retain();

View File

@ -62,7 +62,7 @@ bool LabelAtlas::initWithString(const char *string, const char *charMapFile, uns
bool LabelAtlas::initWithString(const char *string, Texture2D* texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap)
{
CCAssert(string != NULL, "");
CCASSERT(string != NULL, "");
if (AtlasNode::initWithTexture(texture, itemWidth, itemHeight, strlen(string)))
{
_mapStartChar = startCharMap;
@ -96,7 +96,7 @@ bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
Dictionary *dict = Dictionary::createWithContentsOfFile(pathStr.c_str());
CCAssert(((String*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version");
CCASSERT(((String*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version");
std::string texturePathStr = relPathStr + ((String*)dict->objectForKey("textureFilename"))->getCString();
String *textureFilename = String::create(texturePathStr);
@ -113,7 +113,7 @@ bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
//CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues()
{
unsigned int n = _string.length();
int n = _string.length();
const unsigned char *s = (unsigned char*)_string.c_str();
@ -128,9 +128,9 @@ void LabelAtlas::updateAtlasValues()
itemHeightInPixels = _itemHeight;
}
CCAssert( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
CCASSERT( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
for(unsigned int i = 0; i < n; i++) {
for(int i = 0; i < n; i++) {
unsigned char a = s[i] - _mapStartChar;
float row = (float) (a % _itemsPerRow);
@ -178,7 +178,7 @@ void LabelAtlas::updateAtlasValues()
}
if (n > 0 ){
_textureAtlas->setDirty(true);
unsigned int totalQuads = _textureAtlas->getTotalQuads();
int totalQuads = _textureAtlas->getTotalQuads();
if (n > totalQuads) {
_textureAtlas->increaseTotalQuadsWith(n - totalQuads);
}
@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues()
//CCLabelAtlas - LabelProtocol
void LabelAtlas::setString(const char *label)
{
unsigned int len = strlen(label);
int len = strlen(label);
if (len > _textureAtlas->getTotalQuads())
{
_textureAtlas->resizeCapacity(len);

View File

@ -185,7 +185,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(controlFile);
String *contents = String::createWithContentsOfFile(fullpath.c_str());
CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error.");
CCASSERT(contents, "CCBMFontConfiguration::parseConfigFile | Open file error.");
set<unsigned int> *validCharsString = new set<unsigned int>();
@ -270,7 +270,7 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt
int index = line.find('=')+1;
int index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
CCASSERT(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
// file
index = line.find('"')+1;
index2 = line.find('"', index);
@ -311,17 +311,17 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line)
index = line.find("scaleW=") + strlen("scaleW=");
index2 = line.find(' ', index);
value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
CCASSERT(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
// scaleH. sanity check
index = line.find("scaleH=") + strlen("scaleH=");
index2 = line.find(' ', index);
value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
CCASSERT(atoi(value.c_str()) <= Configuration::getInstance()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
// pages. sanity check
index = line.find("pages=") + strlen("pages=");
index2 = line.find(' ', index);
value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) == 1, "CCBitfontAtlas: only supports 1 page");
CCASSERT(atoi(value.c_str()) == 1, "CCBitfontAtlas: only supports 1 page");
// packed (ignore) What does this mean ??
}
@ -466,8 +466,8 @@ bool LabelBMFont::init()
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/)
{
CCAssert(!_configuration, "re-init is no longer supported");
CCAssert( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
CCASSERT(!_configuration, "re-init is no longer supported");
CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
Texture2D *texture = NULL;
@ -1214,7 +1214,7 @@ void LabelBMFont::setFntFile(const char* fntFile)
{
CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile);
CCAssert( newConf, "CCLabelBMFont: Impossible to create font. Please check file");
CCASSERT( newConf, "CCLabelBMFont: Impossible to create font. Please check file");
_fntFile = fntFile;

View File

@ -173,7 +173,7 @@ bool LabelTTF::initWithStringAndTextDefinition(const char *string, FontDefinitio
void LabelTTF::setString(const char *string)
{
CCAssert(string != NULL, "Invalid string");
CCASSERT(string != NULL, "Invalid string");
if (_string.compare(string))
{

View File

@ -402,7 +402,7 @@ bool Layer::ccTouchBegan(Touch *pTouch, Event *pEvent)
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(false, "Layer#ccTouchBegan override me");
CCASSERT(false, "Layer#ccTouchBegan override me");
return true;
}
@ -960,7 +960,7 @@ void LayerGradient::setStartOpacity(GLubyte o)
updateColor();
}
GLubyte LayerGradient::getStartOpacity()
GLubyte LayerGradient::getStartOpacity() const
{
return _startOpacity;
}
@ -971,7 +971,7 @@ void LayerGradient::setEndOpacity(GLubyte o)
updateColor();
}
GLubyte LayerGradient::getEndOpacity()
GLubyte LayerGradient::getEndOpacity() const
{
return _endOpacity;
}
@ -1062,7 +1062,7 @@ LayerMultiplex* LayerMultiplex::createWithArray(Array* arrayOfLayers)
void LayerMultiplex::addLayer(Layer* layer)
{
CCAssert(_layers, "");
CCASSERT(_layers, "");
_layers->addObject(layer);
}
@ -1105,7 +1105,7 @@ bool LayerMultiplex::initWithArray(Array* arrayOfLayers)
void LayerMultiplex::switchTo(unsigned int n)
{
CCAssert( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true);
@ -1116,7 +1116,7 @@ void LayerMultiplex::switchTo(unsigned int n)
void LayerMultiplex::switchToAndReleaseMe(unsigned int n)
{
CCAssert( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" );
this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true);

View File

@ -303,20 +303,45 @@ public:
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
Default: YES
*/
virtual void setCompressedInterpolation(bool bCompressedInterpolation);
virtual bool isCompressedInterpolation() const;
void setCompressedInterpolation(bool bCompressedInterpolation);
bool isCompressedInterpolation() const;
/** Sets the start color of the gradient */
void setStartColor( const Color3B& startColor );
/** Returns the start color of the gradient */
const Color3B& getStartColor() const;
/** Sets the end color of the gradient */
void setEndColor( const Color3B& endColor );
/** Returns the end color of the gradient */
const Color3B& getEndColor() const;
/** Returns the start opacity of the gradient */
void setStartOpacity( GLubyte startOpacity );
/** Returns the start opacity of the gradient */
GLubyte getStartOpacity() const;
/** Returns the end opacity of the gradient */
void setEndOpacity( GLubyte endOpacity );
/** Returns the end opacity of the gradient */
GLubyte getEndOpacity() const;
/** Sets the directional vector that will be used for the gradient.
The default value is vertical direction (0,-1).
*/
void setVector(const Point& alongVector);
/** Returns the directional vector used for the gradient */
const Point& getVector() const;
protected:
virtual void updateColor() override;
CC_PROPERTY_PASS_BY_REF(Color3B, _startColor, StartColor)
CC_PROPERTY_PASS_BY_REF(Color3B, _endColor, EndColor)
CC_PROPERTY(GLubyte, _startOpacity, StartOpacity)
CC_PROPERTY(GLubyte, _endOpacity, EndOpacity)
CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector)
protected:
bool _compressedInterpolation;
Color3B _startColor;
Color3B _endColor;
GLubyte _startOpacity;
GLubyte _endOpacity;
Point _alongVector;
bool _compressedInterpolation;
};

View File

@ -65,7 +65,7 @@ TransitionScene * TransitionScene::create(float t, Scene *scene)
bool TransitionScene::initWithDuration(float t, Scene *scene)
{
CCAssert( scene != NULL, "Argument scene must be non-nil");
CCASSERT( scene != NULL, "Argument scene must be non-nil");
if (Scene::init())
{
@ -82,7 +82,7 @@ bool TransitionScene::initWithDuration(float t, Scene *scene)
}
_outScene->retain();
CCAssert( _inScene != _outScene, "Incoming scene must be different from the outgoing scene" );
CCASSERT( _inScene != _outScene, "Incoming scene must be different from the outgoing scene" );
sceneOrder();

View File

@ -125,7 +125,7 @@ void TransitionProgress::setupTransition()
ProgressTimer* TransitionProgress::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
CCAssert(false, "override me - abstract class");
CCASSERT(false, "override me - abstract class");
return NULL;
}

View File

@ -175,7 +175,7 @@ void Menu::addChild(Node * child, int zOrder)
void Menu::addChild(Node * child, int zOrder, int tag)
{
CCAssert( dynamic_cast<MenuItem*>(child) != NULL, "Menu only supports MenuItem objects as children");
CCASSERT( dynamic_cast<MenuItem*>(child) != NULL, "Menu only supports MenuItem objects as children");
Layer::addChild(child, zOrder, tag);
}
@ -198,7 +198,7 @@ void Menu::onExit()
void Menu::removeChild(Node* child, bool cleanup)
{
MenuItem *pMenuItem = dynamic_cast<MenuItem*>(child);
CCAssert(pMenuItem != NULL, "Menu only supports MenuItem objects as children");
CCASSERT(pMenuItem != NULL, "Menu only supports MenuItem objects as children");
if (_selectedItem == pMenuItem)
{
@ -252,7 +252,7 @@ void Menu::ccTouchEnded(Touch *touch, Event* event)
{
CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event);
CCAssert(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
if (_selectedItem)
{
_selectedItem->unselected();
@ -265,7 +265,7 @@ void Menu::ccTouchCancelled(Touch *touch, Event* event)
{
CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event);
CCAssert(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
if (_selectedItem)
{
_selectedItem->unselected();
@ -276,7 +276,7 @@ void Menu::ccTouchCancelled(Touch *touch, Event* event)
void Menu::ccTouchMoved(Touch* touch, Event* event)
{
CC_UNUSED_PARAM(event);
CCAssert(_state == kMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");
MenuItem *currentItem = this->itemForTouch(touch);
if (currentItem != _selectedItem)
{
@ -368,7 +368,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding)
}
}
void Menu::alignItemsInColumns(unsigned int columns, ...)
void Menu::alignItemsInColumns(int columns, ...)
{
va_list args;
va_start(args, columns);
@ -378,13 +378,14 @@ void Menu::alignItemsInColumns(unsigned int columns, ...)
va_end(args);
}
void Menu::alignItemsInColumns(unsigned int columns, va_list args)
void Menu::alignItemsInColumns(int columns, va_list args)
{
CCASSERT(columns >= 0, "Columns must be >= 0");
Array* rows = Array::create();
while (columns)
{
rows->addObject(Integer::create(columns));
columns = va_arg(args, unsigned int);
columns = va_arg(args, int);
}
alignItemsInColumnsWithArray(rows);
}
@ -407,11 +408,11 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray)
Node* pChild = dynamic_cast<Node*>(pObject);
if (pChild)
{
CCAssert(row < rows.size(), "");
CCASSERT(row < rows.size(), "");
rowColumns = rows[row];
// can not have zero columns on a row
CCAssert(rowColumns, "");
CCASSERT(rowColumns, "");
float tmp = pChild->getContentSize().height;
rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp);
@ -430,7 +431,7 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray)
}
// check if too many rows/columns for available menu items
CCAssert(! columnsOccupied, "");
CCASSERT(! columnsOccupied, "");
Size winSize = Director::getInstance()->getWinSize();
@ -479,7 +480,7 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray)
}
}
void Menu::alignItemsInRows(unsigned int rows, ...)
void Menu::alignItemsInRows(int rows, ...)
{
va_list args;
va_start(args, rows);
@ -489,13 +490,13 @@ void Menu::alignItemsInRows(unsigned int rows, ...)
va_end(args);
}
void Menu::alignItemsInRows(unsigned int rows, va_list args)
void Menu::alignItemsInRows(int rows, va_list args)
{
Array* pArray = Array::create();
while (rows)
{
pArray->addObject(Integer::create(rows));
rows = va_arg(args, unsigned int);
rows = va_arg(args, int);
}
alignItemsInRowsWithArray(pArray);
}
@ -523,11 +524,11 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray)
if (pChild)
{
// check if too many menu items for the amount of rows/columns
CCAssert(column < columns.size(), "");
CCASSERT(column < columns.size(), "");
columnRows = columns[column];
// can't have zero rows on a column
CCAssert(columnRows, "");
CCASSERT(columnRows, "");
// columnWidth = fmaxf(columnWidth, [item contentSize].width);
float tmp = pChild->getContentSize().width;
@ -552,7 +553,7 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray)
}
// check if too many rows/columns for available menu items.
CCAssert(! rowsOccupied, "");
CCASSERT(! rowsOccupied, "");
Size winSize = Director::getInstance()->getWinSize();

View File

@ -98,13 +98,13 @@ public:
void alignItemsHorizontallyWithPadding(float padding);
/** align items in rows of columns */
void alignItemsInColumns(unsigned int columns, ...);
void alignItemsInColumns(unsigned int columns, va_list args);
void alignItemsInColumns(int columns, ...);
void alignItemsInColumns(int columns, va_list args);
void alignItemsInColumnsWithArray(Array* rows);
/** align items in columns of rows */
void alignItemsInRows(unsigned int rows, ...);
void alignItemsInRows(unsigned int rows, va_list args);
void alignItemsInRows(int rows, ...);
void alignItemsInRows(int rows, va_list args);
void alignItemsInRowsWithArray(Array* columns);
/** set event handler priority. By default it is: kMenuTouchPriority */

View File

@ -344,7 +344,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const char *value, const char *cha
// XXX: deprecated
bool MenuItemAtlasFont::initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
{
CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
CCASSERT( value != NULL && strlen(value) != 0, "value length must be greater than 0");
_target = target;
CC_SAFE_RETAIN(_target);
@ -353,7 +353,7 @@ bool MenuItemAtlasFont::initWithString(const char *value, const char *charMapFil
bool MenuItemAtlasFont::initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
{
CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
CCASSERT( value != NULL && strlen(value) != 0, "value length must be greater than 0");
LabelAtlas *label = new LabelAtlas();
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
label->autorelease();
@ -422,7 +422,7 @@ MenuItemFont * MenuItemFont::create(const char *value)
// XXX: deprecated
bool MenuItemFont::initWithString(const char *value, Object* target, SEL_MenuHandler selector)
{
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
CCASSERT( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
_target = target;
CC_SAFE_RETAIN(target);
@ -431,7 +431,7 @@ bool MenuItemFont::initWithString(const char *value, Object* target, SEL_MenuHan
bool MenuItemFont::initWithString(const char *value, const ccMenuCallback& callback)
{
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
CCASSERT( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
_fontName = _globalFontName;
_fontSize = _globalFontSize;

View File

@ -92,7 +92,7 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
{
CCAssert(path != NULL, "Invalid filename");
CCASSERT(path != NULL, "Invalid filename");
Texture2D *texture = TextureCache::getInstance()->addImage(path);
return initWithFade(fade, minSeg, stroke, color, texture);
@ -180,12 +180,12 @@ const BlendFunc& MotionStreak::getBlendFunc(void) const
void MotionStreak::setOpacity(GLubyte opacity)
{
CCAssert(false, "Set opacity no supported");
CCASSERT(false, "Set opacity no supported");
}
GLubyte MotionStreak::getOpacity(void) const
{
CCAssert(false, "Opacity no supported");
CCASSERT(false, "Opacity no supported");
return 0;
}

View File

@ -241,12 +241,12 @@ void ProgressTimer::setAnchorPoint(const Point& anchorPoint)
Node::setAnchorPoint(anchorPoint);
}
Point ProgressTimer::getMidpoint(void)
Point ProgressTimer::getMidpoint() const
{
return _midpoint;
}
void ProgressTimer::setMidpoint(Point midPoint)
void ProgressTimer::setMidpoint(const Point& midPoint)
{
_midpoint = midPoint.getClampPoint(Point::ZERO, Point(1, 1));
}
@ -356,7 +356,7 @@ void ProgressTimer::updateRadial(void)
if(!_vertexData) {
_vertexDataCount = index + 3;
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
}
updateColor();
@ -427,7 +427,7 @@ void ProgressTimer::updateBar(void)
if(!_vertexData) {
_vertexDataCount = 4;
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
}
// TOPLEFT
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y));
@ -448,7 +448,7 @@ void ProgressTimer::updateBar(void)
if(!_vertexData) {
_vertexDataCount = 8;
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
// TOPLEFT 1
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(0,1));
_vertexData[0].vertices = vertexFromAlphaPoint(Point(0,1));

View File

@ -85,6 +85,30 @@ public:
inline bool isReverseDirection() { return _reverseDirection; };
inline void setReverseDirection(bool value) { _reverseDirection = value; };
/**
* Midpoint is used to modify the progress start position.
* If you're using radials type then the midpoint changes the center point
* If you're using bar type the the midpoint changes the bar growth
* it expands from the center but clamps to the sprites edge so:
* you want a left to right then set the midpoint all the way to Point(0,y)
* you want a right to left then set the midpoint all the way to Point(1,y)
* you want a bottom to top then set the midpoint all the way to Point(x,0)
* you want a top to bottom then set the midpoint all the way to Point(x,1)
*/
void setMidpoint(const Point& point);
/** Returns the Midpoint */
Point getMidpoint() const;
/**
* This allows the bar type to move the component at a specific rate
* Set the component to 0 to make sure it stays at 100%.
* For example you want a left to right bar but not have the height stay 100%
* Set the rate to be Point(0,1); and set the midpoint to = Point(0,.5f);
*/
inline void setBarChangeRate(const Point& barChangeRate ) { _barChangeRate = barChangeRate; }
/** Returns the BarChangeRate */
inline Point getBarChangeRate() const { return _barChangeRate; }
// Overrides
virtual void draw(void) override;
void setAnchorPoint(const Point& anchorPoint) override;
@ -102,33 +126,14 @@ protected:
void updateColor(void);
Point boundaryTexCoord(char index);
protected:
ProgressTimerType _type;
Point _midpoint;
Point _barChangeRate;
float _percentage;
Sprite *_sprite;
int _vertexDataCount;
V2F_C4B_T2F *_vertexData;
/**
* Midpoint is used to modify the progress start position.
* If you're using radials type then the midpoint changes the center point
* If you're using bar type the the midpoint changes the bar growth
* it expands from the center but clamps to the sprites edge so:
* you want a left to right then set the midpoint all the way to Point(0,y)
* you want a right to left then set the midpoint all the way to Point(1,y)
* you want a bottom to top then set the midpoint all the way to Point(x,0)
* you want a top to bottom then set the midpoint all the way to Point(x,1)
*/
CC_PROPERTY(Point, _midpoint, Midpoint);
/**
* This allows the bar type to move the component at a specific rate
* Set the component to 0 to make sure it stays at 100%.
* For example you want a left to right bar but not have the height stay 100%
* Set the rate to be Point(0,1); and set the midpoint to = Point(0,.5f);
*/
CC_SYNTHESIZE(Point, _barChangeRate, BarChangeRate);
bool _reverseDirection;
};

View File

@ -249,7 +249,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat)
{
CCAssert(eFormat != kTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture");
CCASSERT(eFormat != kTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture");
bool bRet = false;
void *data = NULL;
@ -329,7 +329,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
}
// check if it worked (probably worth doing :) )
CCAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer");
CCASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer");
_texture->setAliasTexParameters();
@ -622,7 +622,7 @@ bool RenderTexture::saveToFile(const char *szFilePath)
bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
{
bool bRet = false;
CCAssert(format == kImageFormatJPEG || format == kImageFormatPNG,
CCASSERT(format == kImageFormatJPEG || format == kImageFormatPNG,
"the image can only be saved as JPG or PNG format");
Image *pImage = newImage(true);
@ -641,7 +641,7 @@ bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
/* get buffer as Image */
Image* RenderTexture::newImage(bool flipImage)
{
CCAssert(_pixelFormat == kTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image");
CCASSERT(_pixelFormat == kTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image");
if (NULL == _texture)
{

View File

@ -167,23 +167,23 @@ void ParticleBatchNode::addChild(Node * child, int zOrder)
void ParticleBatchNode::addChild(Node * child, int zOrder, int tag)
{
CCAssert( child != NULL, "Argument must be non-NULL");
CCAssert( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
CCASSERT( child != NULL, "Argument must be non-NULL");
CCASSERT( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
ParticleSystem* pChild = (ParticleSystem*)child;
CCAssert( pChild->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id");
CCASSERT( pChild->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id");
// If this is the 1st children, then copy blending function
if( _children->count() == 0 )
{
setBlendFunc(pChild->getBlendFunc());
}
CCAssert( _blendFunc.src == pChild->getBlendFunc().src && _blendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function");
CCASSERT( _blendFunc.src == pChild->getBlendFunc().src && _blendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function");
//no lazy sorting, so don't call super addChild, call helper instead
unsigned int pos = addChildHelper(pChild,zOrder,tag);
//get new atlasIndex
unsigned int atlasIndex = 0;
int atlasIndex = 0;
if (pos != 0)
{
@ -208,8 +208,8 @@ void ParticleBatchNode::addChild(Node * child, int zOrder, int tag)
// this helper is almost equivalent to Node's addChild, but doesn't make use of the lazy sorting
unsigned int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCAssert( child->getParent() == NULL, "child already added. It can't be added again");
CCASSERT( child != NULL, "Argument must be non-nil");
CCASSERT( child->getParent() == NULL, "child already added. It can't be added again");
if( ! _children )
{
@ -238,9 +238,9 @@ unsigned int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int
// Reorder will be done in this function, no "lazy" reorder to particles
void ParticleBatchNode::reorderChild(Node * child, int zOrder)
{
CCAssert( child != NULL, "Child must be non-NULL");
CCAssert( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
CCAssert( _children->containsObject(child), "Child doesn't belong to batch" );
CCASSERT( child != NULL, "Child must be non-NULL");
CCASSERT( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
CCASSERT( _children->containsObject(child), "Child doesn't belong to batch" );
ParticleSystem* pChild = (ParticleSystem*)(child);
@ -266,13 +266,13 @@ void ParticleBatchNode::reorderChild(Node * child, int zOrder)
pChild->release();
// save old altasIndex
unsigned int oldAtlasIndex = pChild->getAtlasIndex();
int oldAtlasIndex = pChild->getAtlasIndex();
// update atlas index
updateAllAtlasIndexes();
// Find new AtlasIndex
unsigned int newAtlasIndex = 0;
int newAtlasIndex = 0;
for( unsigned int i=0;i < _children->count();i++)
{
ParticleSystem* pNode = (ParticleSystem*)_children->objectAtIndex(i);
@ -368,8 +368,8 @@ void ParticleBatchNode::removeChild(Node* child, bool cleanup)
return;
}
CCAssert( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
CCAssert(_children->containsObject(child), "CCParticleBatchNode doesn't contain the sprite. Can't remove it");
CCASSERT( dynamic_cast<ParticleSystem*>(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children");
CCASSERT(_children->containsObject(child), "CCParticleBatchNode doesn't contain the sprite. Can't remove it");
ParticleSystem* pChild = (ParticleSystem*)child;
Node::removeChild(pChild, cleanup);
@ -429,7 +429,7 @@ void ParticleBatchNode::increaseAtlasCapacityTo(unsigned int quantity)
if( ! _textureAtlas->resizeCapacity(quantity) ) {
// serious problems
CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas");
CCAssert(false,"XXX: ParticleBatchNode #increaseAtlasCapacity SHALL handle this assert");
CCASSERT(false,"XXX: ParticleBatchNode #increaseAtlasCapacity SHALL handle this assert");
}
}
@ -443,7 +443,7 @@ void ParticleBatchNode::disableParticle(unsigned int particleIndex)
// ParticleBatchNode - add / remove / reorder helper methods
// add child helper
void ParticleBatchNode::insertChild(ParticleSystem* pSystem, unsigned int index)
void ParticleBatchNode::insertChild(ParticleSystem* pSystem, int index)
{
pSystem->setAtlasIndex(index);

View File

@ -83,7 +83,7 @@ public:
bool initWithFile(const char* fileImage, unsigned int capacity);
/** Inserts a child into the ParticleBatchNode */
void insertChild(ParticleSystem* pSystem, unsigned int index);
void insertChild(ParticleSystem* pSystem, int index);
void removeChildAtIndex(unsigned int index, bool doCleanup);
void removeAllChildrenWithCleanup(bool doCleanup);

View File

@ -170,7 +170,7 @@ bool ParticleSystem::initWithFile(const char *plistFile)
_plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile);
Dictionary *dict = Dictionary::createWithContentsOfFileThreadSafe(_plistFile.c_str());
CCAssert( dict != NULL, "Particles: file not found");
CCASSERT( dict != NULL, "Particles: file not found");
// XXX compute path from a path, should define a function somewhere to do it
string listFilePath = plistFile;
@ -293,7 +293,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
modeB.rotatePerSecondVar = dictionary->valueForKey("rotatePerSecondVariance")->floatValue();
} else {
CCAssert( false, "Invalid emitterType in config file");
CCASSERT( false, "Invalid emitterType in config file");
CC_BREAK_IF(true);
}
@ -353,24 +353,24 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
else
{
const char *textureData = dictionary->valueForKey("textureImageData")->getCString();
CCAssert(textureData, "");
CCASSERT(textureData, "");
int dataLen = strlen(textureData);
if(dataLen != 0)
{
// if it fails, try to get it from the base64-gzipped data
int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen, &buffer);
CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
CCASSERT( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
CC_BREAK_IF(!buffer);
int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated);
CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");
CCASSERT( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");
CC_BREAK_IF(!deflated);
// For android, we should retain it in VolatileTexture::addImage which invoked in TextureCache::getInstance()->addUIImage()
image = new Image();
bool isOK = image->initWithImageData(deflated, deflatedLen);
CCAssert(isOK, "CCParticleSystem: error init image with Data");
CCASSERT(isOK, "CCParticleSystem: error init image with Data");
CC_BREAK_IF(!isOK);
setTexture(TextureCache::getInstance()->addUIImage(image, textureName.c_str()));
@ -378,7 +378,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
image->release();
}
}
CCAssert( this->_texture != NULL, "CCParticleSystem: error loading the texture");
CCASSERT( this->_texture != NULL, "CCParticleSystem: error loading the texture");
}
bRet = true;
}
@ -799,7 +799,7 @@ void ParticleSystem::setTexture(Texture2D* var)
void ParticleSystem::updateBlendFunc()
{
CCAssert(! _batchNode, "Can't change blending functions when the particle is being batched");
CCASSERT(! _batchNode, "Can't change blending functions when the particle is being batched");
if(_texture)
{
@ -858,170 +858,170 @@ bool ParticleSystem::isBlendAdditive() const
// ParticleSystem - Properties of Gravity Mode
void ParticleSystem::setTangentialAccel(float t)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.tangentialAccel = t;
}
float ParticleSystem::getTangentialAccel() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.tangentialAccel;
}
void ParticleSystem::setTangentialAccelVar(float t)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.tangentialAccelVar = t;
}
float ParticleSystem::getTangentialAccelVar() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.tangentialAccelVar;
}
void ParticleSystem::setRadialAccel(float t)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.radialAccel = t;
}
float ParticleSystem::getRadialAccel() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.radialAccel;
}
void ParticleSystem::setRadialAccelVar(float t)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.radialAccelVar = t;
}
float ParticleSystem::getRadialAccelVar() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.radialAccelVar;
}
void ParticleSystem::setRotationIsDir(bool t)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.rotationIsDir = t;
}
bool ParticleSystem::getRotationIsDir() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.rotationIsDir;
}
void ParticleSystem::setGravity(const Point& g)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.gravity = g;
}
const Point& ParticleSystem::getGravity()
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.gravity;
}
void ParticleSystem::setSpeed(float speed)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.speed = speed;
}
float ParticleSystem::getSpeed() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.speed;
}
void ParticleSystem::setSpeedVar(float speedVar)
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
modeA.speedVar = speedVar;
}
float ParticleSystem::getSpeedVar() const
{
CCAssert( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
return modeA.speedVar;
}
// ParticleSystem - Properties of Radius Mode
void ParticleSystem::setStartRadius(float startRadius)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.startRadius = startRadius;
}
float ParticleSystem::getStartRadius() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.startRadius;
}
void ParticleSystem::setStartRadiusVar(float startRadiusVar)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.startRadiusVar = startRadiusVar;
}
float ParticleSystem::getStartRadiusVar() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.startRadiusVar;
}
void ParticleSystem::setEndRadius(float endRadius)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.endRadius = endRadius;
}
float ParticleSystem::getEndRadius() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.endRadius;
}
void ParticleSystem::setEndRadiusVar(float endRadiusVar)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.endRadiusVar = endRadiusVar;
}
float ParticleSystem::getEndRadiusVar() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.endRadiusVar;
}
void ParticleSystem::setRotatePerSecond(float degrees)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.rotatePerSecond = degrees;
}
float ParticleSystem::getRotatePerSecond() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.rotatePerSecond;
}
void ParticleSystem::setRotatePerSecondVar(float degrees)
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
modeB.rotatePerSecondVar = degrees;
}
float ParticleSystem::getRotatePerSecondVar() const
{
CCAssert( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
return modeB.rotatePerSecondVar;
}
@ -1241,7 +1241,7 @@ unsigned int ParticleSystem::getTotalParticles()
void ParticleSystem::setTotalParticles(unsigned int var)
{
CCAssert( var <= _allocatedParticles, "Particle: resizing particle array only supported for quads");
CCASSERT( var <= _allocatedParticles, "Particle: resizing particle array only supported for quads");
_totalParticles = var;
}

View File

@ -345,7 +345,7 @@ protected:
CC_PROPERTY(ParticleBatchNode*, _batchNode, BatchNode);
// index of system in batch node array
CC_SYNTHESIZE(unsigned int, _atlasIndex, AtlasIndex);
CC_SYNTHESIZE(int, _atlasIndex, AtlasIndex);
//true if scaled or rotated
bool _transformSystemDirty;
@ -354,7 +354,6 @@ protected:
/** Is the emitter active */
bool _isActive;
/** Quantity of particles that are being simulated at the moment */
CC_PROPERTY_READONLY(unsigned int, _particleCount, ParticleCount)

View File

@ -215,7 +215,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture)
}
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
{
CCAssert(spriteFrame->getOffsetInPixels().equals(Point::ZERO),
CCASSERT(spriteFrame->getOffsetInPixels().equals(Point::ZERO),
"QuadParticle only supports SpriteFrames with no offsets");
// update texture before updating texture rect
@ -346,14 +346,14 @@ void ParticleSystemQuad::postStep()
// overriding draw method
void ParticleSystemQuad::draw()
{
CCAssert(!_batchNode,"draw should not be called when added to a particleBatchNode");
CCASSERT(!_batchNode,"draw should not be called when added to a particleBatchNode");
CC_NODE_DRAW_SETUP();
ccGLBindTexture2D( _texture->getName() );
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
CCAssert( _particleIdx == _particleCount, "Abnormal error in particle quad");
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
#if CC_TEXTURE_ATLAS_USE_VAO
//
@ -540,8 +540,8 @@ void ParticleSystemQuad::listenBackToForeground(Object *obj)
bool ParticleSystemQuad::allocMemory()
{
CCAssert( ( !_quads && !_indices), "Memory already alloced");
CCAssert( !_batchNode, "Memory should not be alloced when not using batchNode");
CCASSERT( ( !_quads && !_indices), "Memory already alloced");
CCASSERT( !_batchNode, "Memory should not be alloced when not using batchNode");
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);

View File

@ -57,7 +57,7 @@ EGLViewProtocol::~EGLViewProtocol()
void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
{
CCAssert(resolutionPolicy != kResolutionUnKnown, "should set resolutionPolicy");
CCASSERT(resolutionPolicy != kResolutionUnKnown, "should set resolutionPolicy");
if (width == 0.0f || height == 0.0f)
{

View File

@ -146,7 +146,7 @@ public:
else if (SAX_DICT == preState)
{
// add the dictionary into the pre dictionary
CCAssert(! _dictStack.empty(), "The state is wrong!");
CCASSERT(! _dictStack.empty(), "The state is wrong!");
Dictionary* pPreDict = _dictStack.top();
pPreDict->setObject(_curDict, _curKey.c_str());
}
@ -194,7 +194,7 @@ public:
}
else if (preState == SAX_ARRAY)
{
CCAssert(! _arrayStack.empty(), "The state is wrong!");
CCASSERT(! _arrayStack.empty(), "The state is wrong!");
Array* pPreArray = _arrayStack.top();
pPreArray->addObject(_array);
}
@ -300,7 +300,7 @@ public:
{
if (curState == SAX_DICT)
{
CCAssert(!_curKey.empty(), "key not found : <integer/real>");
CCASSERT(!_curKey.empty(), "key not found : <integer/real>");
}
_curValue.append(pText->getCString());
@ -501,7 +501,7 @@ void FileUtils::purgeCachedEntries()
unsigned char* FileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{
unsigned char * pBuffer = NULL;
CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters.");
CCASSERT(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters.");
*pSize = 0;
do
{
@ -555,7 +555,7 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c
pBuffer = new unsigned char[FileInfo.uncompressed_size];
int CC_UNUSED nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
CCASSERT(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
*pSize = FileInfo.uncompressed_size;
unzCloseCurrentFile(pFile);
@ -609,7 +609,7 @@ std::string FileUtils::getPathForFilename(const std::string& filename, const std
std::string FileUtils::fullPathForFilename(const char* pszFileName)
{
CCAssert(pszFileName != NULL, "CCFileUtils: Invalid path");
CCASSERT(pszFileName != NULL, "CCFileUtils: Invalid path");
std::string strFileName = pszFileName;
if (isAbsolutePath(pszFileName))

View File

@ -124,7 +124,7 @@ static void addObjectToNSArray(Object *object, NSMutableArray *array)
static void addValueToDict(id key, id value, Dictionary* pDict)
{
// the key must be a string
CCAssert([key isKindOfClass:[NSString class]], "The key should be a string!");
CCASSERT([key isKindOfClass:[NSString class]], "The key should be a string!");
std::string pKey = [key UTF8String];
// the value is a new dictionary

View File

@ -36,13 +36,13 @@ Application* Application::sm_pSharedApplication = 0;
Application::Application()
{
CCAssert(! sm_pSharedApplication, "sm_pSharedApplication already exist");
CCASSERT(! sm_pSharedApplication, "sm_pSharedApplication already exist");
sm_pSharedApplication = this;
}
Application::~Application()
{
CCAssert(this == sm_pSharedApplication, "sm_pSharedApplication != this");
CCASSERT(this == sm_pSharedApplication, "sm_pSharedApplication != this");
sm_pSharedApplication = 0;
}
@ -71,7 +71,7 @@ TargetPlatform Application::getTargetPlatform()
Application* Application::getInstance()
{
CCAssert(sm_pSharedApplication, "sm_pSharedApplication not set");
CCASSERT(sm_pSharedApplication, "sm_pSharedApplication not set");
return sm_pSharedApplication;
}

View File

@ -121,7 +121,7 @@ static void addObjectToNSArray(Object *object, NSMutableArray *array)
static void addValueToDict(id key, id value, Dictionary* pDict)
{
// the key must be a string
CCAssert([key isKindOfClass:[NSString class]], "The key should be a string!");
CCASSERT([key isKindOfClass:[NSString class]], "The key should be a string!");
std::string pKey = [key UTF8String];
// the value is a new dictionary

View File

@ -312,8 +312,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
{
bool bRet = false;
CCAssert(pText, "Invalid pText");
CCAssert(pInfo, "Invalid pInfo");
CCASSERT(pText, "Invalid pText");
CCASSERT(pInfo, "Invalid pInfo");
do {
NSString * string = [NSString stringWithUTF8String:pText];
@ -643,7 +643,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
case kTexture2DPixelFormat_RGB565:
case kTexture2DPixelFormat_A8:
tempData = (unsigned char*)(this->getData());
CCAssert(tempData != NULL, "NULL image data.");
CCASSERT(tempData != NULL, "NULL image data.");
if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh)
{
@ -668,7 +668,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
break;
case kTexture2DPixelFormat_RGB888:
tempData = (unsigned char*)(this->getData());
CCAssert(tempData != NULL, "NULL image data.");
CCASSERT(tempData != NULL, "NULL image data.");
if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh)
{
data = new unsigned char[POTHigh * POTWide * 3];
@ -690,7 +690,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
}
break;
default:
CCAssert(0, "Invalid pixel format");
CCASSERT(0, "Invalid pixel format");
}
// Repack the pixel data into the right format

View File

@ -60,8 +60,8 @@ GLProgram::~GLProgram()
CCLOGINFO("cocos2d: %s %d deallocing %p", __FUNCTION__, __LINE__, this);
// there is no need to delete the shaders. They should have been already deleted.
CCAssert(_vertShader == 0, "Vertex Shaders should have been already deleted");
CCAssert(_fragShader == 0, "Fragment Shaders should have been already deleted");
CCASSERT(_vertShader == 0, "Vertex Shaders should have been already deleted");
CCASSERT(_fragShader == 0, "Fragment Shaders should have been already deleted");
if (_program)
{
@ -223,7 +223,7 @@ void GLProgram::updateUniforms()
bool GLProgram::link()
{
CCAssert(_program != 0, "Cannot link invalid program");
CCASSERT(_program != 0, "Cannot link invalid program");
GLint status = GL_TRUE;
@ -335,8 +335,8 @@ bool GLProgram::updateUniformLocation(GLint location, GLvoid* data, unsigned int
GLint GLProgram::getUniformLocationForName(const char* name) const
{
CCAssert(name != NULL, "Invalid uniform name" );
CCAssert(_program != 0, "Invalid operation. Cannot get uniform location when program is not initialized");
CCASSERT(name != NULL, "Invalid uniform name" );
CCASSERT(_program != 0, "Invalid operation. Cannot get uniform location when program is not initialized");
return glGetUniformLocation(_program, name);
}

View File

@ -152,7 +152,7 @@ void ccGLBindTexture2D(GLuint textureId)
void ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId)
{
#if CC_ENABLE_GL_STATE_CACHE
CCAssert(textureUnit < kMaxActiveTexture, "textureUnit is too big");
CCASSERT(textureUnit < kMaxActiveTexture, "textureUnit is too big");
if (s_uCurrentBoundTexture[textureUnit] != textureId)
{
s_uCurrentBoundTexture[textureUnit] = textureId;

View File

@ -235,19 +235,19 @@ void AnimationCache::addAnimationsWithDictionary(Dictionary* dictionary)
parseVersion2(animations);
break;
default:
CCAssert(false, "Invalid animation format");
CCASSERT(false, "Invalid animation format");
}
}
/** Read an NSDictionary from a plist file and parse it automatically for animations */
void AnimationCache::addAnimationsWithFile(const char* plist)
{
CCAssert( plist, "Invalid texture file name");
CCASSERT( plist, "Invalid texture file name");
std::string path = FileUtils::getInstance()->fullPathForFilename(plist);
Dictionary* dict = Dictionary::createWithContentsOfFile(path.c_str());
CCAssert( dict, "CCAnimationCache: File could not be found");
CCASSERT( dict, "CCAnimationCache: File could not be found");
addAnimationsWithDictionary(dict);
}

View File

@ -123,7 +123,7 @@ Sprite* Sprite::createWithSpriteFrameName(const char *pszSpriteFrameName)
#if COCOS2D_DEBUG > 0
char msg[256] = {0};
sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName);
CCAssert(pFrame != NULL, msg);
CCASSERT(pFrame != NULL, msg);
#endif
return createWithSpriteFrame(pFrame);
@ -207,7 +207,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect)
bool Sprite::initWithTexture(Texture2D *pTexture)
{
CCAssert(pTexture != NULL, "Invalid texture for sprite");
CCASSERT(pTexture != NULL, "Invalid texture for sprite");
Rect rect = Rect::ZERO;
rect.size = pTexture->getContentSize();
@ -217,7 +217,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture)
bool Sprite::initWithFile(const char *pszFilename)
{
CCAssert(pszFilename != NULL, "Invalid filename for sprite");
CCASSERT(pszFilename != NULL, "Invalid filename for sprite");
Texture2D *pTexture = TextureCache::getInstance()->addImage(pszFilename);
if (pTexture)
@ -235,7 +235,7 @@ bool Sprite::initWithFile(const char *pszFilename)
bool Sprite::initWithFile(const char *pszFilename, const Rect& rect)
{
CCAssert(pszFilename != NULL, "");
CCASSERT(pszFilename != NULL, "");
Texture2D *pTexture = TextureCache::getInstance()->addImage(pszFilename);
if (pTexture)
@ -251,7 +251,7 @@ bool Sprite::initWithFile(const char *pszFilename, const Rect& rect)
bool Sprite::initWithSpriteFrame(SpriteFrame *pSpriteFrame)
{
CCAssert(pSpriteFrame != NULL, "");
CCASSERT(pSpriteFrame != NULL, "");
bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect());
setDisplayFrame(pSpriteFrame);
@ -261,7 +261,7 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *pSpriteFrame)
bool Sprite::initWithSpriteFrameName(const char *pszSpriteFrameName)
{
CCAssert(pszSpriteFrameName != NULL, "");
CCASSERT(pszSpriteFrameName != NULL, "");
SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pszSpriteFrameName);
return initWithSpriteFrame(pFrame);
@ -281,7 +281,7 @@ Sprite* Sprite::initWithCGImage(CGImageRef pImage)
/*
Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
{
CCAssert(pImage != NULL);
CCASSERT(pImage != NULL);
// XXX: possible bug. See issue #349. New API should be added
Texture2D *pTexture = TextureCache::getInstance()->addCGImage(pImage, pszKey);
@ -448,7 +448,7 @@ void Sprite::setTextureCoords(Rect rect)
void Sprite::updateTransform(void)
{
CCAssert(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode");
CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode");
// recalculate matrix only if it is dirty
if( isDirty() ) {
@ -469,7 +469,7 @@ void Sprite::updateTransform(void)
}
else
{
CCAssert( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
_transformToBatch = AffineTransformConcat( getNodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch );
}
@ -547,7 +547,7 @@ void Sprite::draw(void)
{
CC_PROFILER_START_CATEGORY(kProfilerCategorySprite, "CCSprite - draw");
CCAssert(!_batchNode, "If Sprite is being rendered by SpriteBatchNode, Sprite#draw SHOULD NOT be called");
CCASSERT(!_batchNode, "If Sprite is being rendered by SpriteBatchNode, Sprite#draw SHOULD NOT be called");
CC_NODE_DRAW_SETUP();
@ -621,13 +621,13 @@ void Sprite::addChild(Node *pChild, int zOrder)
void Sprite::addChild(Node *pChild, int zOrder, int tag)
{
CCAssert(pChild != NULL, "Argument must be non-NULL");
CCASSERT(pChild != NULL, "Argument must be non-NULL");
if (_batchNode)
{
Sprite* pChildSprite = dynamic_cast<Sprite*>(pChild);
CCAssert( pChildSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode");
CCAssert(pChildSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "");
CCASSERT( pChildSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode");
CCASSERT(pChildSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "");
//put it in descendants array of batch node
_batchNode->appendChild(pChildSprite);
@ -643,8 +643,8 @@ void Sprite::addChild(Node *pChild, int zOrder, int tag)
void Sprite::reorderChild(Node *pChild, int zOrder)
{
CCAssert(pChild != NULL, "");
CCAssert(_children->containsObject(pChild), "");
CCASSERT(pChild != NULL, "");
CCASSERT(_children->containsObject(pChild), "");
if (zOrder == pChild->getZOrder())
{
@ -695,7 +695,7 @@ void Sprite::sortAllChildren()
{
if (_reorderChildDirty)
{
int i = 0,j = 0,length = _children->data->num;
int i = 0, j = 0, length = _children->data->num;
Node** x = (Node**)_children->data->arr;
Node *tempItem = NULL;
@ -841,7 +841,7 @@ void Sprite::setAnchorPoint(const Point& anchor)
void Sprite::ignoreAnchorPointForPosition(bool value)
{
CCAssert(! _batchNode, "ignoreAnchorPointForPosition is invalid in Sprite");
CCASSERT(! _batchNode, "ignoreAnchorPointForPosition is invalid in Sprite");
Node::ignoreAnchorPointForPosition(value);
}
@ -903,7 +903,7 @@ void Sprite::updateColor(void)
// renders using batch node
if (_batchNode)
{
if (_atlasIndex != SpriteIndexNotInitialized)
if (_atlasIndex != kSpriteIndexNotInitialized)
{
_textureAtlas->updateQuad(&_quad, _atlasIndex);
}
@ -981,15 +981,15 @@ void Sprite::setDisplayFrame(SpriteFrame *pNewFrame)
void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{
CCAssert(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
CCASSERT(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
Animation *a = AnimationCache::getInstance()->animationByName(animationName);
CCAssert(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");
CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");
AnimationFrame* frame = (AnimationFrame*)a->getFrames()->objectAtIndex(frameIndex);
AnimationFrame* frame = static_cast<AnimationFrame*>( a->getFrames()->objectAtIndex(frameIndex) );
CCAssert(frame, "CCSprite#setDisplayFrame. Invalid frame");
CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame");
setDisplayFrame(frame->getSpriteFrame());
}
@ -1023,7 +1023,7 @@ void Sprite::setBatchNode(SpriteBatchNode *pobSpriteBatchNode)
// self render
if( ! _batchNode ) {
_atlasIndex = SpriteIndexNotInitialized;
_atlasIndex = kSpriteIndexNotInitialized;
setTextureAtlas(NULL);
_recursiveDirty = false;
setDirty(false);
@ -1049,7 +1049,7 @@ void Sprite::setBatchNode(SpriteBatchNode *pobSpriteBatchNode)
void Sprite::updateBlendFunc(void)
{
CCAssert (! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode");
CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode");
// it is possible to have an untextured sprite
if (! _texture || ! _texture->hasPremultipliedAlpha())
@ -1089,9 +1089,9 @@ static unsigned char cc_2x2_white_image[] = {
void Sprite::setTexture(Texture2D *texture)
{
// If batchnode, then texture id should be the same
CCAssert(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode");
CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode");
// accept texture==nil as argument
CCAssert( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
CCASSERT( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
if (NULL == texture)
{
@ -1103,7 +1103,7 @@ void Sprite::setTexture(Texture2D *texture)
{
Image* image = new Image();
bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::kFmtRawData, 2, 2, 8);
CCAssert(isOK, "The 2x2 empty texture was created unsuccessfully.");
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);
CC_SAFE_RELEASE(image);

View File

@ -53,9 +53,6 @@ struct transformValues_;
* @{
*/
#define SpriteIndexNotInitialized 0xffffffff /// Sprite invalid index on the SpriteBatchNode
/**
* Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
*
@ -85,6 +82,9 @@ class CC_DLL Sprite : public NodeRGBA, public TextureProtocol
#endif // EMSCRIPTEN
{
public:
static const int kSpriteIndexNotInitialized = -1; /// Sprite invalid index on the SpriteBatchNode
/// @{
/// @name Creators
@ -375,13 +375,13 @@ public:
/**
* Returns the index used on the TextureAtlas.
*/
inline unsigned int getAtlasIndex(void) const { return _atlasIndex; }
inline int getAtlasIndex(void) const { return _atlasIndex; }
/**
* Sets the index used on the TextureAtlas.
* @warning Don't modify this value unless you know what you are doing
*/
inline void setAtlasIndex(unsigned int uAtlasIndex) { _atlasIndex = uAtlasIndex; }
inline void setAtlasIndex(int atlasIndex) { _atlasIndex = atlasIndex; }
/**
* Returns the rect of the Sprite in points
@ -499,29 +499,29 @@ protected:
//
// Data used when the sprite is rendered using a SpriteSheet
//
TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference)
unsigned int _atlasIndex; /// Absolute (real) Index on the SpriteSheet
SpriteBatchNode* _batchNode; /// Used batch node (weak reference)
TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference)
int _atlasIndex; /// Absolute (real) Index on the SpriteSheet
SpriteBatchNode* _batchNode; /// Used batch node (weak reference)
bool _dirty; /// Whether the sprite needs to be updated
bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated
bool _hasChildren; /// Whether the sprite contains children
bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible
AffineTransform _transformToBatch;
bool _dirty; /// Whether the sprite needs to be updated
bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated
bool _hasChildren; /// Whether the sprite contains children
bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible
AffineTransform _transformToBatch;
//
// Data used when the sprite is self-rendered
//
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
Texture2D* _texture; /// Texture2D object that is used to render the sprite
Texture2D* _texture; /// Texture2D object that is used to render the sprite
//
// Shared data
//
// texture
Rect _rect; /// Retangle of Texture2D
bool _rectRotated; /// Whether the texture is rotated
Rect _rect; /// Retangle of Texture2D
bool _rectRotated; /// Whether the texture is rotated
// Offset Position (used by Zwoptex)
Point _offsetPosition;

View File

@ -45,7 +45,7 @@ NS_CC_BEGIN
* creation with Texture2D
*/
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/)
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity/* = kDefaultSpriteBatchCapacity*/)
{
SpriteBatchNode *batchNode = new SpriteBatchNode();
batchNode->initWithTexture(tex, capacity);
@ -58,7 +58,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, unsigned int
* creation with File Image
*/
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/)
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = kDefaultSpriteBatchCapacity*/)
{
SpriteBatchNode *batchNode = new SpriteBatchNode();
batchNode->initWithFile(fileImage, capacity);
@ -70,8 +70,10 @@ SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, unsigned int cap
/*
* init with Texture2D
*/
bool SpriteBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity)
bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
{
CCASSERT(capacity>=0, "Capacity must be >= 0");
_blendFunc.src = CC_BLEND_SRC;
_blendFunc.dst = CC_BLEND_DST;
_textureAtlas = new TextureAtlas();
@ -106,7 +108,7 @@ bool SpriteBatchNode::init()
/*
* init with FileImage
*/
bool SpriteBatchNode::initWithFile(const char* fileImage, unsigned int capacity)
bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity)
{
Texture2D *pTexture2D = TextureCache::getInstance()->addImage(fileImage);
return initWithTexture(pTexture2D, capacity);
@ -169,11 +171,11 @@ void SpriteBatchNode::visit(void)
void SpriteBatchNode::addChild(Node *child, int zOrder, int tag)
{
CCAssert(child != NULL, "child should not be null");
CCAssert(dynamic_cast<Sprite*>(child) != NULL, "CCSpriteBatchNode only supports Sprites as children");
CCASSERT(child != NULL, "child should not be null");
CCASSERT(dynamic_cast<Sprite*>(child) != NULL, "CCSpriteBatchNode only supports Sprites as children");
Sprite *pSprite = (Sprite*)(child);
// check Sprite is using the same texture id
CCAssert(pSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCSprite is not using the same texture id");
CCASSERT(pSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCSprite is not using the same texture id");
Node::addChild(child, zOrder, tag);
@ -193,8 +195,8 @@ void SpriteBatchNode::addChild(Node *child, int zOrder)
// override reorderChild
void SpriteBatchNode::reorderChild(Node *child, int zOrder)
{
CCAssert(child != NULL, "the child should not be null");
CCAssert(_children->containsObject(child), "Child doesn't belong to Sprite");
CCASSERT(child != NULL, "the child should not be null");
CCASSERT(_children->containsObject(child), "Child doesn't belong to Sprite");
if (zOrder == child->getZOrder())
{
@ -216,7 +218,7 @@ void SpriteBatchNode::removeChild(Node *child, bool cleanup)
return;
}
CCAssert(_children->containsObject(pSprite), "sprite batch node should contain the child");
CCASSERT(_children->containsObject(pSprite), "sprite batch node should contain the child");
// cleanup before removing
removeSpriteFromAtlas(pSprite);
@ -420,7 +422,7 @@ void SpriteBatchNode::increaseAtlasCapacity(void)
{
// serious problems
CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas");
CCAssert(false, "Not enough memory to resize the atlas");
CCASSERT(false, "Not enough memory to resize the atlas");
}
}
@ -548,7 +550,7 @@ unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *pobSprite, int nZ)
}
// Should not happen. Error calculating Z on SpriteSheet
CCAssert(0, "should not run here");
CCASSERT(0, "should not run here");
return 0;
}
@ -697,10 +699,10 @@ void SpriteBatchNode::setTexture(Texture2D *texture)
// SpriteSheet Extension
//implementation SpriteSheet (TMXTiledMapExtension)
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, unsigned int index)
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, int index)
{
CCAssert( sprite != NULL, "Argument must be non-NULL");
CCAssert( dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
CCASSERT( sprite != NULL, "Argument must be non-NULL");
CCASSERT( dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
// make needed room
while(index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads())
@ -722,10 +724,10 @@ void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, unsigned int index)
sprite->updateTransform();
}
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, unsigned int index)
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, int index)
{
CCAssert(sprite != NULL, "Argument must be non-nil");
CCAssert(dynamic_cast<Sprite*>(sprite) != NULL, "CCSpriteBatchNode only supports Sprites as children");
CCASSERT(sprite != NULL, "Argument must be non-nil");
CCASSERT(dynamic_cast<Sprite*>(sprite) != NULL, "CCSpriteBatchNode only supports Sprites as children");
// make needed room
while (index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads())
@ -745,10 +747,10 @@ void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, unsigned int index)
sprite->updateTransform();
}
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, unsigned int z, int aTag)
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int aTag)
{
CCAssert( child != NULL, "Argument must be non-NULL");
CCAssert( dynamic_cast<Sprite*>(child), "CCSpriteBatchNode only supports Sprites as children");
CCASSERT( child != NULL, "Argument must be non-NULL");
CCASSERT( dynamic_cast<Sprite*>(child), "CCSpriteBatchNode only supports Sprites as children");
// quad index is Z
child->setAtlasIndex(z);

View File

@ -41,7 +41,6 @@ NS_CC_BEGIN
* @{
*/
#define kDefaultSpriteBatchCapacity 29
class Sprite;
@ -62,11 +61,13 @@ class Sprite;
*/
class CC_DLL SpriteBatchNode : public Node, public TextureProtocol
{
static const int kDefaultSpriteBatchCapacity = 29;
public:
/** creates a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
static SpriteBatchNode* createWithTexture(Texture2D* tex, unsigned int capacity);
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity);
static SpriteBatchNode* createWithTexture(Texture2D* tex) {
return SpriteBatchNode::createWithTexture(tex, kDefaultSpriteBatchCapacity);
}
@ -75,7 +76,7 @@ public:
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
static SpriteBatchNode* create(const char* fileImage, unsigned int capacity);
static SpriteBatchNode* create(const char* fileImage, int capacity);
static SpriteBatchNode* create(const char* fileImage) {
return SpriteBatchNode::create(fileImage, kDefaultSpriteBatchCapacity);
}
@ -86,12 +87,12 @@ public:
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
bool initWithTexture(Texture2D *tex, unsigned int capacity);
bool initWithTexture(Texture2D *tex, int capacity);
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
bool initWithFile(const char* fileImage, unsigned int capacity);
bool initWithFile(const char* fileImage, int capacity);
bool init();
// property
@ -153,16 +154,16 @@ protected:
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
*/
void insertQuadFromSprite(Sprite *sprite, unsigned int index);
void insertQuadFromSprite(Sprite *sprite, int index);
/** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
*/
void updateQuadFromSprite(Sprite *sprite, unsigned int index);
void updateQuadFromSprite(Sprite *sprite, int index);
/* This is the opposite of "addQuadFromSprite.
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
*/
SpriteBatchNode * addSpriteWithoutQuad(Sprite*child, unsigned int z, int aTag);
SpriteBatchNode * addSpriteWithoutQuad(Sprite*child, int z, int aTag);
private:
void updateAtlasIndex(Sprite* sprite, int* curIndex);

View File

@ -98,7 +98,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
}
// check the format
CCAssert(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
DictElement* pElement = NULL;
CCDICT_FOREACH(framesDict, pElement)
@ -213,7 +213,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D *
void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName)
{
CCAssert(textureFileName, "texture name should not be null");
CCASSERT(textureFileName, "texture name should not be null");
Texture2D *texture = TextureCache::getInstance()->addImage(textureFileName);
if (texture)
@ -228,7 +228,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* te
void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
{
CCAssert(pszPlist, "plist filename should not be NULL");
CCASSERT(pszPlist, "plist filename should not be NULL");
if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end())
{

View File

@ -151,7 +151,7 @@ void ProfilingEndTimingBlock(const char *timerName)
Profiler* p = Profiler::getInstance();
ProfilingTimer* timer = (ProfilingTimer*)p->_activeTimers->objectForKey(timerName);
CCAssert(timer, "CCProfilingTimer not found");
CCASSERT(timer, "CCProfilingTimer not found");
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
@ -171,7 +171,7 @@ void ProfilingResetTimingBlock(const char *timerName)
Profiler* p = Profiler::getInstance();
ProfilingTimer *timer = (ProfilingTimer*)p->_activeTimers->objectForKey(timerName);
CCAssert(timer, "CCProfilingTimer not found");
CCASSERT(timer, "CCProfilingTimer not found");
timer->reset();
}

View File

@ -43,7 +43,7 @@ ComponentContainer::~ComponentContainer(void)
Component* ComponentContainer::get(const char *pName) const
{
Component* pRet = NULL;
CCAssert(pName != NULL, "Argument must be non-nil");
CCASSERT(pName != NULL, "Argument must be non-nil");
do {
CC_BREAK_IF(NULL == pName);
CC_BREAK_IF(NULL == _components);
@ -56,8 +56,8 @@ Component* ComponentContainer::get(const char *pName) const
bool ComponentContainer::add(Component *pCom)
{
bool bRet = false;
CCAssert(pCom != NULL, "Argument must be non-nil");
CCAssert(pCom->getOwner() == NULL, "Component already added. It can't be added again");
CCASSERT(pCom != NULL, "Argument must be non-nil");
CCASSERT(pCom->getOwner() == NULL, "Component already added. It can't be added again");
do
{
if (_components == NULL)
@ -68,7 +68,7 @@ bool ComponentContainer::add(Component *pCom)
}
Component *pComponent = dynamic_cast<Component*>(_components->objectForKey(pCom->getName()));
CCAssert(pComponent == NULL, "Component already added. It can't be added again");
CCASSERT(pComponent == NULL, "Component already added. It can't be added again");
CC_BREAK_IF(pComponent);
pCom->setOwner(_owner);
_components->setObject(pCom, pCom->getName());
@ -81,7 +81,7 @@ bool ComponentContainer::add(Component *pCom)
bool ComponentContainer::remove(const char *pName)
{
bool bRet = false;
CCAssert(pName != NULL, "Argument must be non-nil");
CCASSERT(pName != NULL, "Argument must be non-nil");
do
{
CC_BREAK_IF(!_components);

View File

@ -62,7 +62,7 @@ void ccArrayDoubleCapacity(ccArray *arr)
arr->max *= 2;
Object** newArr = (Object**)realloc( arr->arr, arr->max * sizeof(Object*) );
// will fail when there's not enough memory
CCAssert(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory");
CCASSERT(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory");
arr->arr = newArr;
}
@ -93,7 +93,7 @@ void ccArrayShrink(ccArray *arr)
}
arr->arr = (Object**)realloc(arr->arr,newSize * sizeof(Object*) );
CCAssert(arr->arr!=NULL,"could not reallocate the memory");
CCASSERT(arr->arr!=NULL,"could not reallocate the memory");
}
}
@ -119,7 +119,7 @@ bool ccArrayContainsObject(ccArray *arr, Object* object)
/** Appends an object. Behavior undefined if array doesn't have enough capacity. */
void ccArrayAppendObject(ccArray *arr, Object* object)
{
CCAssert(object != NULL, "Invalid parameter!");
CCASSERT(object != NULL, "Invalid parameter!");
object->retain();
arr->arr[arr->num] = object;
arr->num++;
@ -152,8 +152,8 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr)
/** Inserts an object at index */
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, unsigned int index)
{
CCAssert(index<=arr->num, "Invalid index. Out of bounds");
CCAssert(object != NULL, "Invalid parameter!");
CCASSERT(index<=arr->num, "Invalid index. Out of bounds");
CCASSERT(object != NULL, "Invalid parameter!");
ccArrayEnsureExtraCapacity(arr, 1);
@ -171,8 +171,8 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, unsigned int index
/** Swaps two objects */
void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2)
{
CCAssert(index1 < arr->num, "(1) Invalid index. Out of bounds");
CCAssert(index2 < arr->num, "(2) Invalid index. Out of bounds");
CCASSERT(index1 < arr->num, "(1) Invalid index. Out of bounds");
CCASSERT(index2 < arr->num, "(2) Invalid index. Out of bounds");
Object* object1 = arr->arr[index1];
@ -193,7 +193,7 @@ void ccArrayRemoveAllObjects(ccArray *arr)
Behavior undefined if index outside [0, num-1]. */
void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/)
{
CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds");
CCASSERT(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds");
if (bReleaseObj)
{
CC_SAFE_RELEASE(arr->arr[index]);
@ -336,7 +336,7 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value)
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index)
{
CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index");
CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index");
unsigned int remaining = arr->num - index;
// make sure it has enough capacity

View File

@ -47,10 +47,10 @@ inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, int len)
// check if key was set
// make sure to call caw_setkey_part() for all 4 key parts
CCAssert(s_uEncryptedPvrKeyParts[0] != 0, "Cocos2D: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCAssert(s_uEncryptedPvrKeyParts[1] != 0, "Cocos2D: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCAssert(s_uEncryptedPvrKeyParts[2] != 0, "Cocos2D: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCAssert(s_uEncryptedPvrKeyParts[3] != 0, "Cocos2D: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCASSERT(s_uEncryptedPvrKeyParts[0] != 0, "Cocos2D: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCASSERT(s_uEncryptedPvrKeyParts[1] != 0, "Cocos2D: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCASSERT(s_uEncryptedPvrKeyParts[2] != 0, "Cocos2D: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
CCASSERT(s_uEncryptedPvrKeyParts[3] != 0, "Cocos2D: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?");
// create long key
if(!s_bEncryptionKeyIsValid)
@ -235,8 +235,8 @@ int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out)
int len;
unsigned int offset = 0;
CCAssert(out, "");
CCAssert(&*out, "");
CCASSERT(out, "");
CCASSERT(&*out, "");
gzFile inFile = gzopen(path, "rb");
if( inFile == NULL ) {
@ -302,8 +302,8 @@ int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out)
int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
{
CCAssert(out, "");
CCAssert(&*out, "");
CCASSERT(out, "");
CCASSERT(&*out, "");
// load file into memory
unsigned char* compressed = NULL;
@ -416,8 +416,8 @@ int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
void ZipUtils::ccSetPvrEncryptionKeyPart(int index, unsigned int value)
{
CCAssert(index >= 0, "Cocos2d: key part index cannot be less than 0");
CCAssert(index <= 3, "Cocos2d: key part index cannot be greater than 3");
CCASSERT(index >= 0, "Cocos2d: key part index cannot be less than 0");
CCASSERT(index <= 3, "Cocos2d: key part index cannot be greater than 3");
if(s_uEncryptedPvrKeyParts[index] != value)
{
@ -556,7 +556,7 @@ unsigned char *ZipFile::getFileData(const std::string &fileName, unsigned long *
pBuffer = new unsigned char[fileInfo.uncompressed_size];
int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, pBuffer, fileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
if (pSize)
{

View File

@ -244,7 +244,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat,
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
break;
default:
CCAssert(0, "NSInternalInconsistencyException");
CCASSERT(0, "NSInternalInconsistencyException");
}
@ -480,7 +480,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
}
else
{
CCAssert(false, "Not supported alignment format!");
CCASSERT(false, "Not supported alignment format!");
return false;
}
@ -556,7 +556,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
#else
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled;
CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
CCASSERT(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
Image* pImage = new Image();
do
@ -719,7 +719,7 @@ void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
void Texture2D::generateMipmap()
{
CCAssert( _pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
CCASSERT( _pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
ccGLBindTexture2D( _name );
glGenerateMipmap(GL_TEXTURE_2D);
_hasMipmaps = true;
@ -732,7 +732,7 @@ bool Texture2D::hasMipmaps() const
void Texture2D::setTexParameters(const ccTexParams &texParams)
{
CCAssert( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
CCASSERT( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
(_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE),
"GL_CLAMP_TO_EDGE should be used in NPOT dimensions");
@ -822,7 +822,7 @@ const char* Texture2D::getStringForFormat() const
return "PVRTC2";
default:
CCAssert(false , "unrecognized pixel format");
CCASSERT(false , "unrecognized pixel format");
CCLOG("stringForFormat: %ld, cannot give useful result", (long)_pixelFormat);
break;
}
@ -883,7 +883,7 @@ unsigned int Texture2D::getBitsPerPixelForFormat(Texture2DPixelFormat format) co
break;
default:
ret = -1;
CCAssert(false , "unrecognized pixel format");
CCASSERT(false , "unrecognized pixel format");
CCLOG("bitsPerPixelForFormat: %ld, cannot give useful result", (long)format);
break;
}

View File

@ -71,12 +71,12 @@ TextureAtlas::~TextureAtlas()
#endif
}
unsigned int TextureAtlas::getTotalQuads() const
int TextureAtlas::getTotalQuads() const
{
return _totalQuads;
}
unsigned int TextureAtlas::getCapacity() const
int TextureAtlas::getCapacity() const
{
return _capacity;
}
@ -107,7 +107,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad *var)
// TextureAtlas - alloc & init
TextureAtlas * TextureAtlas::create(const char* file, unsigned int capacity)
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
{
TextureAtlas * pTextureAtlas = new TextureAtlas();
if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity))
@ -119,7 +119,7 @@ TextureAtlas * TextureAtlas::create(const char* file, unsigned int capacity)
return NULL;
}
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, unsigned int capacity)
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
{
TextureAtlas * pTextureAtlas = new TextureAtlas();
if (pTextureAtlas && pTextureAtlas->initWithTexture(texture, capacity))
@ -131,7 +131,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, unsigned int
return NULL;
}
bool TextureAtlas::initWithFile(const char * file, unsigned int capacity)
bool TextureAtlas::initWithFile(const char * file, int capacity)
{
// retained in property
Texture2D *texture = TextureCache::getInstance()->addImage(file);
@ -147,9 +147,11 @@ bool TextureAtlas::initWithFile(const char * file, unsigned int capacity)
}
}
bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity)
{
// CCAssert(texture != NULL, "texture should not be null");
CCASSERT(capacity>=0, "Capacity must be >= 0");
// CCASSERT(texture != NULL, "texture should not be null");
_capacity = capacity;
_totalQuads = 0;
@ -158,7 +160,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
CC_SAFE_RETAIN(_texture);
// Re-initialization is not allowed
CCAssert(_quads == NULL && _indices == NULL, "");
CCASSERT(_quads == NULL && _indices == NULL, "");
_quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) );
_indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) );
@ -222,7 +224,7 @@ void TextureAtlas::setupIndices()
if (_capacity == 0)
return;
for( unsigned int i=0; i < _capacity; i++)
for( int i=0; i < _capacity; i++)
{
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
_indices[i*6+0] = i*4+0;
@ -308,9 +310,9 @@ void TextureAtlas::mapBuffers()
// TextureAtlas - Update, Insert, Move & Remove
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
{
CCAssert( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
_totalQuads = MAX( index+1, _totalQuads);
@ -321,12 +323,12 @@ void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
}
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
{
CCAssert( index < _capacity, "insertQuadWithTexture: Invalid index");
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
_totalQuads++;
CCAssert( _totalQuads <= _capacity, "invalid totalQuads");
CCASSERT( _totalQuads <= _capacity, "invalid totalQuads");
// issue #575. index can be > totalQuads
unsigned int remaining = (_totalQuads-1) - index;
@ -345,13 +347,13 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
}
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount)
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
{
CCAssert(index + amount <= _capacity, "insertQuadWithTexture: Invalid index + amount");
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
_totalQuads += amount;
CCAssert( _totalQuads <= _capacity, "invalid totalQuads");
CCASSERT( _totalQuads <= _capacity, "invalid totalQuads");
// issue #575. index can be > totalQuads
int remaining = (_totalQuads-1) - index - amount;
@ -364,9 +366,9 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsi
}
unsigned int max = index + amount;
unsigned int j = 0;
for (unsigned int i = index; i < max ; i++)
int max = index + amount;
int j = 0;
for (int i = index; i < max ; i++)
{
_quads[index] = quads[j];
index++;
@ -376,10 +378,10 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsi
_dirty = true;
}
void TextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int newIndex)
void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
{
CCAssert( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCAssert( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
if( oldIndex == newIndex )
{
@ -387,9 +389,9 @@ void TextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int newIn
}
// because it is ambiguous in iphone, so we implement abs ourselves
// unsigned int howMany = abs( oldIndex - newIndex);
unsigned int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex);
unsigned int dst = oldIndex;
unsigned int src = oldIndex + 1;
int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex);
int dst = oldIndex;
int src = oldIndex + 1;
if( oldIndex > newIndex)
{
dst = newIndex+1;
@ -403,15 +405,13 @@ void TextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int newIn
_dirty = true;
}
void TextureAtlas::removeQuadAtIndex(unsigned int index)
void TextureAtlas::removeQuadAtIndex(int index)
{
CCAssert( index < _totalQuads, "removeQuadAtIndex: Invalid index");
unsigned int remaining = (_totalQuads-1) - index;
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
int remaining = (_totalQuads-1) - index;
// last object doesn't need to be moved
if( remaining )
@ -424,14 +424,13 @@ void TextureAtlas::removeQuadAtIndex(unsigned int index)
_dirty = true;
}
void TextureAtlas::removeQuadsAtIndex(unsigned int index, unsigned int amount)
void TextureAtlas::removeQuadsAtIndex(int index, int amount)
{
CCAssert(index + amount <= _totalQuads, "removeQuadAtIndex: index + amount out of bounds");
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
unsigned int remaining = (_totalQuads) - (index + amount);
int remaining = (_totalQuads) - (index + amount);
_totalQuads -= amount;
@ -449,13 +448,14 @@ void TextureAtlas::removeAllQuads()
}
// TextureAtlas - Resize
bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
bool TextureAtlas::resizeCapacity(int newCapacity)
{
CCASSERT(newCapacity>=0, "capacity >= 0");
if( newCapacity == _capacity )
{
return true;
}
unsigned int uOldCapactiy = _capacity;
int oldCapactiy = _capacity;
// update capacity and totolQuads
_totalQuads = MIN(_totalQuads, newCapacity);
_capacity = newCapacity;
@ -476,9 +476,9 @@ bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
else
{
tmpQuads = (V3F_C4B_T2F_Quad*)realloc( _quads, sizeof(_quads[0]) * _capacity );
if (tmpQuads != NULL && _capacity > uOldCapactiy)
if (tmpQuads != NULL && _capacity > oldCapactiy)
{
memset(tmpQuads+uOldCapactiy, 0, (_capacity - uOldCapactiy)*sizeof(_quads[0]) );
memset(tmpQuads+oldCapactiy, 0, (_capacity - oldCapactiy)*sizeof(_quads[0]) );
}
}
@ -494,9 +494,9 @@ bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
else
{
tmpIndices = (GLushort*)realloc( _indices, sizeof(_indices[0]) * _capacity * 6 );
if (tmpIndices != NULL && _capacity > uOldCapactiy)
if (tmpIndices != NULL && _capacity > oldCapactiy)
{
memset( tmpIndices+uOldCapactiy, 0, (_capacity-uOldCapactiy) * 6 * sizeof(_indices[0]) );
memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) );
}
}
@ -522,15 +522,17 @@ bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
return true;
}
void TextureAtlas::increaseTotalQuadsWith(unsigned int amount)
void TextureAtlas::increaseTotalQuadsWith(int amount)
{
CCASSERT(amount>=0, "amount >= 0");
_totalQuads += amount;
}
void TextureAtlas::moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount, unsigned int newIndex)
void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
{
CCAssert(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCAssert(oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCASSERT(oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
if( oldIndex == newIndex )
{
@ -558,20 +560,22 @@ void TextureAtlas::moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount
_dirty = true;
}
void TextureAtlas::moveQuadsFromIndex(unsigned int index, unsigned int newIndex)
void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
{
CCAssert(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
}
void TextureAtlas::fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount)
void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount)
{
CCASSERT(index>=0 && amount>=0, "values must be >= 0");
V3F_C4B_T2F_Quad quad;
memset(&quad, 0, sizeof(quad));
unsigned int to = index + amount;
for (unsigned int i = index ; i < to ; i++)
int to = index + amount;
for (int i = index ; i < to ; i++)
{
_quads[i] = quad;
}
@ -584,17 +588,19 @@ void TextureAtlas::drawQuads()
this->drawNumberOfQuads(_totalQuads, 0);
}
void TextureAtlas::drawNumberOfQuads(unsigned int n)
void TextureAtlas::drawNumberOfQuads(int numberOfQuads)
{
this->drawNumberOfQuads(n, 0);
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
this->drawNumberOfQuads(numberOfQuads, 0);
}
void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
{
if (0 == n)
{
void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start)
{
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");
if(!numberOfQuads)
return;
}
ccGLBindTexture2D(_texture->getName());
#if CC_TEXTURE_ATLAS_USE_VAO
@ -614,9 +620,9 @@ void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW);
// option 3: orphaning + glMapBuffer
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (n-start), NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW);
void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
memcpy(buf, _quads, sizeof(_quads[0])* (n-start));
memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start));
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -631,9 +637,9 @@ void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
#endif
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
#else
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
#if CC_REBIND_INDICES_BUFFER
@ -654,7 +660,7 @@ void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
// XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty)
{
glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] );
glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] );
_dirty = false;
}
@ -672,9 +678,9 @@ void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
#else
glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glBindBuffer(GL_ARRAY_BUFFER, 0);

View File

@ -59,13 +59,13 @@ public:
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.
*/
static TextureAtlas* create(const char* file , unsigned int capacity);
static TextureAtlas* create(const char* file , int capacity);
/** creates a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for n Quads.
* The TextureAtlas capacity can be increased in runtime.
*/
static TextureAtlas* createWithTexture(Texture2D *texture, unsigned int capacity);
static TextureAtlas* createWithTexture(Texture2D *texture, int capacity);
TextureAtlas();
virtual ~TextureAtlas();
@ -75,7 +75,7 @@ public:
*
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/
bool initWithFile(const char* file, unsigned int capacity);
bool initWithFile(const char* file, int capacity);
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for Quads.
@ -83,43 +83,43 @@ public:
*
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/
bool initWithTexture(Texture2D *texture, unsigned int capacity);
bool initWithTexture(Texture2D *texture, int capacity);
/** updates a Quad (texture, vertex and color) at a certain index
* index must be between 0 and the atlas capacity - 1
@since v0.8
*/
void updateQuad(V3F_C4B_T2F_Quad* quad, unsigned int index);
void updateQuad(V3F_C4B_T2F_Quad* quad, int index);
/** Inserts a Quad (texture, vertex and color) at a certain index
index must be between 0 and the atlas capacity - 1
@since v0.8
*/
void insertQuad(V3F_C4B_T2F_Quad* quad, unsigned int index);
void insertQuad(V3F_C4B_T2F_Quad* quad, int index);
/** Inserts a c array of quads at a given index
index must be between 0 and the atlas capacity - 1
this method doesn't enlarge the array when amount + index > totalQuads
@since v1.1
*/
void insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount);
void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount);
/** Removes the quad that is located at a certain index and inserts it at a new index
This operation is faster than removing and inserting in a quad in 2 different steps
@since v0.7.2
*/
void insertQuadFromIndex(unsigned int fromIndex, unsigned int newIndex);
void insertQuadFromIndex(int fromIndex, int newIndex);
/** removes a quad at a given index number.
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
@since v0.7.2
*/
void removeQuadAtIndex(unsigned int index);
void removeQuadAtIndex(int index);
/** removes a amount of quads starting from index
@since 1.1
*/
void removeQuadsAtIndex(unsigned int index, unsigned int amount);
void removeQuadsAtIndex(int index, int amount);
/** removes all Quads.
The TextureAtlas capacity remains untouched. No memory is freed.
The total number of quads to be drawn will be 0
@ -132,19 +132,19 @@ public:
* It returns YES if the resize was successful.
* If it fails to resize the capacity it will return NO with a new capacity of 0.
*/
bool resizeCapacity(unsigned int n);
bool resizeCapacity(int capacity);
/**
Used internally by ParticleBatchNode
don't use this unless you know what you're doing
@since 1.1
*/
void increaseTotalQuadsWith(unsigned int amount);
void increaseTotalQuadsWith(int amount);
/** Moves an amount of quads from oldIndex at newIndex
@since v1.1
*/
void moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount, unsigned int newIndex);
void moveQuadsFromIndex(int oldIndex, int amount, int newIndex);
/**
Moves quads from index till totalQuads to the newIndex
@ -152,26 +152,26 @@ public:
This method doesn't enlarge the array if newIndex + quads to be moved > capacity
@since 1.1
*/
void moveQuadsFromIndex(unsigned int index, unsigned int newIndex);
void moveQuadsFromIndex(int index, int newIndex);
/**
Ensures that after a realloc quads are still empty
Used internally by ParticleBatchNode
@since 1.1
*/
void fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount);
void fillWithEmptyQuadsFromIndex(int index, int amount);
/** draws n quads
* n can't be greater than the capacity of the Atlas
*/
void drawNumberOfQuads(unsigned int n);
void drawNumberOfQuads(int n);
/** draws n quads from an index (offset).
n + start can't be greater than the capacity of the atlas
@since v1.0
*/
void drawNumberOfQuads(unsigned int n, unsigned int start);
void drawNumberOfQuads(int numberOfQuads, int start);
/** draws all the Atlas's Quads
*/
@ -206,9 +206,9 @@ protected:
/** quantity of quads that are going to be drawn */
CC_PROPERTY_READONLY(unsigned int, _totalQuads, TotalQuads)
CC_PROPERTY_READONLY(int, _totalQuads, TotalQuads)
/** quantity of quads that can be stored with the current texture atlas size */
CC_PROPERTY_READONLY(unsigned int, _capacity, Capacity)
CC_PROPERTY_READONLY(int, _capacity, Capacity)
/** Texture of the texture atlas */
CC_PROPERTY(Texture2D *, _texture, Texture)
/** Quads that are going to be rendered */

View File

@ -75,7 +75,7 @@ TextureCache::TextureCache()
, _asyncRefCount(0)
, _textures(new Dictionary())
{
CCAssert(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton.");
CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton.");
}
TextureCache::~TextureCache()
@ -117,7 +117,7 @@ Dictionary* TextureCache::snapshotTextures()
void TextureCache::addImageAsync(const char *path, Object *target, SEL_CallFuncO selector)
{
CCAssert(path != NULL, "TextureCache: fileimage MUST not be NULL");
CCASSERT(path != NULL, "TextureCache: fileimage MUST not be NULL");
Texture2D *texture = NULL;
@ -327,7 +327,7 @@ void TextureCache::addImageAsyncCallBack(float dt)
Texture2D * TextureCache::addImage(const char * path)
{
CCAssert(path != NULL, "TextureCache: fileimage MUST not be NULL");
CCASSERT(path != NULL, "TextureCache: fileimage MUST not be NULL");
Texture2D * texture = NULL;
Image* pImage = NULL;
@ -417,7 +417,7 @@ Texture2D * TextureCache::addImage(const char * path)
Texture2D * TextureCache::addPVRImage(const char* path)
{
CCAssert(path != NULL, "TextureCache: fileimage MUST not be nil");
CCASSERT(path != NULL, "TextureCache: fileimage MUST not be nil");
Texture2D* texture = NULL;
std::string key(path);
@ -450,7 +450,7 @@ Texture2D * TextureCache::addPVRImage(const char* path)
Texture2D* TextureCache::addETCImage(const char* path)
{
CCAssert(path != NULL, "TextureCache: fileimage MUST not be nil");
CCASSERT(path != NULL, "TextureCache: fileimage MUST not be nil");
Texture2D* texture = NULL;
std::string key(path);
@ -479,7 +479,7 @@ Texture2D* TextureCache::addETCImage(const char* path)
Texture2D* TextureCache::addUIImage(Image *image, const char *key)
{
CCAssert(image != NULL, "TextureCache: image MUST not be nil");
CCASSERT(image != NULL, "TextureCache: image MUST not be nil");
Texture2D * texture = NULL;
// textureForKey() use full path,so the key should be full path
@ -615,7 +615,7 @@ void TextureCache::dumpCachedTextureInfo()
CCDICT_FOREACH(_textures, pElement)
{
Texture2D* tex = static_cast<Texture2D*>(pElement->getObject());
unsigned int bpp = tex->bitsPerPixelForFormat();
unsigned int bpp = tex->getBitsPerPixelForFormat();
// Each texture takes up width * height * bytesPerPixel bytes.
unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
totalBytes += bytes;

View File

@ -377,7 +377,7 @@ bool TexturePVR::unpackPVRv2Data(unsigned char* data, unsigned int len)
_numberOfMipmaps++;
//Check that we didn't overflow
CCAssert(_numberOfMipmaps < CC_PVRMIPMAP_MAX,
CCASSERT(_numberOfMipmaps < CC_PVRMIPMAP_MAX,
"TexturePVR: Maximum number of mipmaps reached. Increase the CC_PVRMIPMAP_MAX value");
dataOffset += packetLength;
@ -471,7 +471,7 @@ bool TexturePVR::unpackPVRv3Data(unsigned char* dataPointer, unsigned int dataLe
bytes = dataPointer;
_numberOfMipmaps = header->numberOfMipmaps;
CCAssert(_numberOfMipmaps < CC_PVRMIPMAP_MAX, "TexturePVR: Maximum number of mimpaps reached. Increate the CC_PVRMIPMAP_MAX value");
CCASSERT(_numberOfMipmaps < CC_PVRMIPMAP_MAX, "TexturePVR: Maximum number of mimpaps reached. Increate the CC_PVRMIPMAP_MAX value");
for (unsigned int i = 0; i < _numberOfMipmaps; i++)
{
@ -520,7 +520,7 @@ bool TexturePVR::unpackPVRv3Data(unsigned char* dataPointer, unsigned int dataLe
_asMipmaps[i].len = packetLength;
dataOffset += packetLength;
CCAssert(dataOffset <= dataLength, "CCTexurePVR: Invalid lenght");
CCASSERT(dataOffset <= dataLength, "CCTexurePVR: Invalid lenght");
width = MAX(width >> 1, 1);

View File

@ -77,12 +77,12 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag)
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(tag);
CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
}
void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCASSERT( child != NULL, "Argument must be non-nil");
PointObject *obj = PointObject::pointWithPoint(ratio, offset);
obj->setChild(child);
ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj);

View File

@ -57,7 +57,13 @@ public:
virtual ~ParallaxNode();
void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset);
/** Sets an array of layers for the Parallax node */
void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; }
/** Returns the array of layers of the Parallax node */
struct _ccArray* getParallaxArray() { return _parallaxArray; }
const struct _ccArray* getParallaxArray() const { return _parallaxArray; }
//
// Overrides
//
@ -65,12 +71,12 @@ public:
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(void) override;
private:
Point absolutePosition();
protected:
Point absolutePosition();
Point _lastPosition;
/** array that holds the offset / ratio of the children */
CC_SYNTHESIZE(struct _ccArray *, _parallaxArray, ParallaxArray)
struct _ccArray* _parallaxArray;
};
// end of tilemap_parallax_nodes group

View File

@ -193,7 +193,7 @@ void TMXLayer::setupTiles()
}
}
CCAssert( _maxGID >= _tileSet->_firstGid &&
CCASSERT( _maxGID >= _tileSet->_firstGid &&
_minGID >= _tileSet->_firstGid, "TMX: Only 1 tileset per layer is supported");
}
@ -322,8 +322,8 @@ Sprite* TMXLayer::reusedTileWithRect(Rect rect)
// TMXLayer - obtaining tiles/gids
Sprite * TMXLayer::getTileAt(const Point& pos)
{
CCAssert(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCAssert(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
Sprite *tile = nullptr;
unsigned int gid = this->getTileGIDAt(pos);
@ -359,8 +359,8 @@ Sprite * TMXLayer::getTileAt(const Point& pos)
unsigned int TMXLayer::getTileGIDAt(const Point& pos, ccTMXTileFlags* flags/* = nullptr*/)
{
CCAssert(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCAssert(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
int idx = (int)(pos.x + pos.y * _layerSize.width);
// Bits on the far end of the 32-bit global tile ID are used for tile flags
@ -473,7 +473,7 @@ unsigned int TMXLayer::atlasIndexForExistantZ(unsigned int z)
int key=z;
int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts);
CCAssert(item, "TMX atlas index not found. Shall not happen");
CCASSERT(item, "TMX atlas index not found. Shall not happen");
int index = ((size_t)item - (size_t)_atlasIndexArray->arr) / sizeof(void*);
return index;
@ -502,9 +502,9 @@ void TMXLayer::setTileGID(unsigned int gid, const Point& pos)
void TMXLayer::setTileGID(unsigned int gid, const Point& pos, ccTMXTileFlags flags)
{
CCAssert(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCAssert(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
CCAssert(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" );
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
CCASSERT(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" );
ccTMXTileFlags currentFlags;
unsigned int currentGID = getTileGIDAt(pos, &currentFlags);
@ -553,7 +553,7 @@ void TMXLayer::addChild(Node * child, int zOrder, int tag)
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(tag);
CCAssert(0, "addChild: is not supported on TMXLayer. Instead use setTileGID:at:/tileAt:");
CCASSERT(0, "addChild: is not supported on TMXLayer. Instead use setTileGID:at:/tileAt:");
}
void TMXLayer::removeChild(Node* node, bool cleanup)
@ -565,7 +565,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
return;
}
CCAssert(_children->containsObject(sprite), "Tile does not belong to TMXLayer");
CCASSERT(_children->containsObject(sprite), "Tile does not belong to TMXLayer");
unsigned int atlasIndex = sprite->getAtlasIndex();
unsigned int zz = (size_t)_atlasIndexArray->arr[atlasIndex];
@ -576,8 +576,8 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
void TMXLayer::removeTileAt(const Point& pos)
{
CCAssert(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCAssert(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
unsigned int gid = getTileGIDAt(pos);
@ -637,7 +637,7 @@ Point TMXLayer::calculateLayerOffset(const Point& pos)
(_mapTileSize.height /2 ) * (-pos.x - pos.y));
break;
case TMXOrientationHex:
CCAssert(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet");
CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet");
break;
}
return ret;
@ -703,10 +703,10 @@ int TMXLayer::getVertexZForPos(const Point& pos)
ret = (int)(-(_layerSize.height-pos.y));
break;
case TMXOrientationHex:
CCAssert(0, "TMX Hexa zOrder not supported");
CCASSERT(0, "TMX Hexa zOrder not supported");
break;
default:
CCAssert(0, "TMX invalid value");
CCASSERT(0, "TMX invalid value");
break;
}
}

View File

@ -58,7 +58,7 @@ TMXTiledMap* TMXTiledMap::createWithXML(const char* tmxString, const char* resou
bool TMXTiledMap::initWithTMXFile(const char *tmxFile)
{
CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi NULL");
CCASSERT(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi NULL");
setContentSize(Size::ZERO);
@ -68,7 +68,7 @@ bool TMXTiledMap::initWithTMXFile(const char *tmxFile)
{
return false;
}
CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
buildWithMapInfo(mapInfo);
return true;
@ -80,7 +80,7 @@ bool TMXTiledMap::initWithXML(const char* tmxString, const char* resourcePath)
TMXMapInfo *mapInfo = TMXMapInfo::formatWithXML(tmxString, resourcePath);
CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
buildWithMapInfo(mapInfo);
return true;
@ -232,7 +232,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
// public
TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
{
CCAssert(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!");
CCASSERT(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!");
Object* pObj = NULL;
CCARRAY_FOREACH(_children, pObj)
{
@ -252,7 +252,7 @@ TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName)
{
CCAssert(groupName != NULL && strlen(groupName) > 0, "Invalid group name!");
CCASSERT(groupName != NULL && strlen(groupName) > 0, "Invalid group name!");
std::string sGroupName = groupName;
if (_objectGroups && _objectGroups->count()>0)

View File

@ -500,9 +500,9 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribZlib);
}
CCAssert( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" );
CCASSERT( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" );
}
CCAssert( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported" );
CCASSERT( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported" );
}
else if (elementName == "object")
@ -718,7 +718,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name)
int sizeHint = (int)(s.width * s.height * sizeof(unsigned int));
int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint);
CCAssert(inflatedLen == sizeHint, "");
CCASSERT(inflatedLen == sizeHint, "");
inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warnings in compiler

View File

@ -88,20 +88,23 @@ This information is obtained from the TMX file.
*/
class CC_DLL TMXLayerInfo : public Object
{
CC_PROPERTY(Dictionary*, _properties, Properties);
public:
TMXLayerInfo();
virtual ~TMXLayerInfo();
void setProperties(Dictionary *properties);
Dictionary* getProperties();
Dictionary *_properties;
std::string _name;
Size _layerSize;
Size _layerSize;
unsigned int *_tiles;
bool _visible;
unsigned char _opacity;
bool _ownTiles;
unsigned int _minGID;
unsigned int _maxGID;
Point _offset;
public:
TMXLayerInfo();
virtual ~TMXLayerInfo();
Point _offset;
};
/** @brief TMXTilesetInfo contains the information about the tilesets like:

View File

@ -93,7 +93,7 @@ void TileMapAtlas::releaseMap()
void TileMapAtlas::calculateItemsToRender()
{
CCAssert( _TGAInfo != NULL, "tgaInfo must be non-nil");
CCASSERT( _TGAInfo != NULL, "tgaInfo must be non-nil");
_itemsToRender = 0;
for(int x=0;x < _TGAInfo->width; x++ )
@ -112,7 +112,7 @@ void TileMapAtlas::calculateItemsToRender()
void TileMapAtlas::loadTGAfile(const char *file)
{
CCAssert( file != NULL, "file must be non-nil");
CCASSERT( file != NULL, "file must be non-nil");
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(file);
@ -125,7 +125,7 @@ void TileMapAtlas::loadTGAfile(const char *file)
#if 1
if( _TGAInfo->status != TGA_OK )
{
CCAssert(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file");
CCASSERT(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file");
}
#endif
}
@ -133,11 +133,11 @@ void TileMapAtlas::loadTGAfile(const char *file)
// TileMapAtlas - Atlas generation / updates
void TileMapAtlas::setTile(const Color3B& tile, const Point& position)
{
CCAssert(_TGAInfo != NULL, "tgaInfo must not be nil");
CCAssert(_posToAtlasIndex != NULL, "posToAtlasIndex must not be nil");
CCAssert(position.x < _TGAInfo->width, "Invalid position.x");
CCAssert(position.y < _TGAInfo->height, "Invalid position.x");
CCAssert(tile.r != 0, "R component must be non 0");
CCASSERT(_TGAInfo != NULL, "tgaInfo must not be nil");
CCASSERT(_posToAtlasIndex != NULL, "posToAtlasIndex must not be nil");
CCASSERT(position.x < _TGAInfo->width, "Invalid position.x");
CCASSERT(position.y < _TGAInfo->height, "Invalid position.x");
CCASSERT(tile.r != 0, "R component must be non 0");
Color3B *ptr = (Color3B*)_TGAInfo->imageData;
Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
@ -160,9 +160,9 @@ void TileMapAtlas::setTile(const Color3B& tile, const Point& position)
Color3B TileMapAtlas::getTileAt(const Point& position) const
{
CCAssert( _TGAInfo != NULL, "tgaInfo must not be nil");
CCAssert( position.x < _TGAInfo->width, "Invalid position.x");
CCAssert( position.y < _TGAInfo->height, "Invalid position.y");
CCASSERT( _TGAInfo != NULL, "tgaInfo must not be nil");
CCASSERT( position.x < _TGAInfo->width, "Invalid position.x");
CCASSERT( position.y < _TGAInfo->height, "Invalid position.y");
Color3B *ptr = (Color3B*)_TGAInfo->imageData;
Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
@ -170,9 +170,9 @@ Color3B TileMapAtlas::getTileAt(const Point& position) const
return value;
}
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index)
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, int index)
{
CCAssert( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[index]);
@ -228,7 +228,7 @@ void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, un
quad->bl.colors = color;
_textureAtlas->setDirty(true);
unsigned int totalQuads = _textureAtlas->getTotalQuads();
int totalQuads = _textureAtlas->getTotalQuads();
if (index + 1 > totalQuads) {
_textureAtlas->increaseTotalQuadsWith(index + 1 - totalQuads);
}
@ -236,7 +236,7 @@ void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, un
void TileMapAtlas::updateAtlasValues()
{
CCAssert( _TGAInfo != NULL, "tgaInfo must be non-nil");
CCASSERT( _TGAInfo != NULL, "tgaInfo must be non-nil");
int total = 0;

View File

@ -83,7 +83,7 @@ public:
private:
void loadTGAfile(const char *file);
void calculateItemsToRender();
void updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index);
void updateAtlasValueAt(const Point& pos, const Color3B& value, int index);
void updateAtlasValues();
protected:

View File

@ -57,7 +57,7 @@ void TouchDispatcher::setDispatchEvents(bool bDispatchEvents)
+(id) allocWithZone:(Zone *)zone
{
@synchronized(self) {
CCAssert(sharedDispatcher == nil, @"Attempted to allocate a second instance of a singleton.");
CCASSERT(sharedDispatcher == nil, @"Attempted to allocate a second instance of a singleton.");
return [super allocWithZone:zone];
}
return nil; // on subsequent allocation attempts return nil
@ -118,7 +118,7 @@ void TouchDispatcher::forceAddHandler(TouchHandler *pHandler, Array *pArray)
if (h->getDelegate() == pHandler->getDelegate())
{
CCAssert(0, "");
CCASSERT(0, "");
return;
}
}
@ -275,7 +275,7 @@ TouchHandler* TouchDispatcher::findHandler(TouchDelegate *pDelegate)
TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelegate)
{
CCAssert(pArray != NULL && pDelegate != NULL, "");
CCASSERT(pArray != NULL && pDelegate != NULL, "");
Object* pObj = NULL;
CCARRAY_FOREACH(pArray, pObj)
@ -297,13 +297,13 @@ void TouchDispatcher::rearrangeHandlers(Array *pArray)
void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate)
{
CCAssert(pDelegate != NULL, "");
CCASSERT(pDelegate != NULL, "");
TouchHandler *handler = NULL;
handler = this->findHandler(pDelegate);
CCAssert(handler != NULL, "");
CCASSERT(handler != NULL, "");
if (handler->getPriority() != nPriority)
{
@ -318,7 +318,7 @@ void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate)
//
void TouchDispatcher::touches(Set *pTouches, Event *pEvent, unsigned int uIndex)
{
CCAssert(uIndex >= 0 && uIndex < 4, "");
CCASSERT(uIndex >= 0 && uIndex < 4, "");
Set *pMutableTouches;
_locked = true;

View File

@ -89,7 +89,7 @@ TouchHandler* TouchHandler::handlerWithDelegate(TouchDelegate *pDelegate, int nP
bool TouchHandler::initWithDelegate(TouchDelegate *pDelegate, int nPriority)
{
CCAssert(pDelegate != NULL, "touch delegate should not be null");
CCASSERT(pDelegate != NULL, "touch delegate should not be null");
_delegate = pDelegate;

View File

@ -136,13 +136,13 @@ bool Armature::init(const char *name)
_name = name;
AnimationData *animationData = armatureDataManager->getAnimationData(name);
CCAssert(animationData, "CCAnimationData not exist! ");
CCASSERT(animationData, "CCAnimationData not exist! ");
_animation->setAnimationData(animationData);
ArmatureData *armatureData = armatureDataManager->getArmatureData(name);
CCAssert(armatureData, "");
CCASSERT(armatureData, "");
_armatureData = armatureData;
@ -245,8 +245,8 @@ Bone *Armature::createBone(const char *boneName)
void Armature::addBone(Bone *bone, const char *parentName)
{
CCAssert( bone != NULL, "Argument must be non-nil");
CCAssert(_boneDic->objectForKey(bone->getName()) == NULL, "bone already added. It can't be added again");
CCASSERT( bone != NULL, "Argument must be non-nil");
CCASSERT(_boneDic->objectForKey(bone->getName()) == NULL, "bone already added. It can't be added again");
if (NULL != parentName)
{
@ -280,7 +280,7 @@ void Armature::addBone(Bone *bone, const char *parentName)
void Armature::removeBone(Bone *bone, bool recursion)
{
CCAssert(bone != NULL, "bone must be added to the bone dictionary!");
CCASSERT(bone != NULL, "bone must be added to the bone dictionary!");
bone->setArmature(NULL);
bone->removeFromParent(recursion);
@ -302,7 +302,7 @@ Bone *Armature::getBone(const char *_name) const
void Armature::changeBoneParent(Bone *bone, const char *parentName)
{
CCAssert(bone != NULL, "bone must be added to the bone dictionary!");
CCASSERT(bone != NULL, "bone must be added to the bone dictionary!");
bone->getParentBone()->getChildren()->removeObject(bone);
bone->setParentBone(NULL);

View File

@ -128,7 +128,7 @@ bool Bone::init(const char *name)
void Bone::setBoneData(BoneData *boneData)
{
CCAssert(NULL != boneData, "_boneData must not be NULL");
CCASSERT(NULL != boneData, "_boneData must not be NULL");
_boneData = boneData;
_boneData->retain();
@ -175,7 +175,7 @@ void Bone::update(float delta)
_worldTransform.tx = _tweenData->x;
_worldTransform.ty = _tweenData->y;
_worldTransform = AffineTransformConcat(nodeToParentTransform(), _worldTransform);
_worldTransform = AffineTransformConcat(getNodeToParentTransform(), _worldTransform);
if(_parent)
{
@ -222,8 +222,8 @@ void Bone::updateColor()
void Bone::addChildBone(Bone *child)
{
CCAssert( NULL != child, "Argument must be non-nil");
CCAssert( NULL == child->_parent, "child already added. It can't be added again");
CCASSERT( NULL != child, "Argument must be non-nil");
CCASSERT( NULL == child->_parent, "child already added. It can't be added again");
if(!_children)
{

View File

@ -135,10 +135,10 @@ void ArmatureAnimation::setAnimationScale(float animationScale )
void ArmatureAnimation::play(const char *animationName, int durationTo, int durationTween, int loop, int tweenEasing)
{
CCAssert(_animationData, "_animationData can not be null");
CCASSERT(_animationData, "_animationData can not be null");
_movementData = _animationData->getMovement(animationName);
CCAssert(_movementData, "_movementData can not be null");
CCASSERT(_movementData, "_movementData can not be null");
//! Get key frame count
_rawDuration = _movementData->duration;

View File

@ -79,7 +79,7 @@ void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, f
ColliderDetector *detector = decoDisplay->getColliderDetector();
if (detector)
{
AffineTransform t = AffineTransformConcat(bone->nodeToArmatureTransform(), bone->getArmature()->nodeToWorldTransform());
AffineTransform t = AffineTransformConcat(bone->nodeToArmatureTransform(), bone->getArmature()->getNodeToWorldTransform());
detector->updateTransform(t);
}
}

View File

@ -122,7 +122,7 @@ void DisplayManager::removeDisplay(int index)
void DisplayManager::changeDisplayByIndex(int index, bool force)
{
CCAssert( (_decoDisplayList ? index < (int)_decoDisplayList->count() : true), "the _index value is out of range");
CCASSERT( (_decoDisplayList ? index < (int)_decoDisplayList->count() : true), "the _index value is out of range");
_forceChangeDisplay = force;

View File

@ -252,7 +252,7 @@ void Texture2DMutable::restore()
this->apply();
#else
//You should set CC_MUTABLE_TEXTURE_SAVE_ORIGINAL_DATA 1 in Texture2DMutable.h
CCAssert(false, "Exception: MutableTexture.restore was disabled by the user.");
CCASSERT(false, "Exception: MutableTexture.restore was disabled by the user.");
#endif
}
@ -280,7 +280,7 @@ void Texture2DMutable::apply()
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _pixelsWide, _pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data_);
break;
default:
CCAssert(false, "NSInternalInconsistencyException");
CCASSERT(false, "NSInternalInconsistencyException");
}
glBindTexture(GL_TEXTURE_2D, 0);

View File

@ -77,7 +77,7 @@ ColliderDetector::~ColliderDetector()
bool ColliderDetector::init()
{
_colliderBodyList = Array::create();
CCAssert(_colliderBodyList, "create _colliderBodyList failed!");
CCASSERT(_colliderBodyList, "create _colliderBodyList failed!");
_colliderBodyList->retain();
return true;

View File

@ -78,15 +78,15 @@ bool ArmatureDataManager::init()
do
{
_armarureDatas = Dictionary::create();
CCAssert(_armarureDatas, "create ArmatureDataManager::_armarureDatas fail!");
CCASSERT(_armarureDatas, "create ArmatureDataManager::_armarureDatas fail!");
_armarureDatas->retain();
_animationDatas = Dictionary::create();
CCAssert(_animationDatas, "create ArmatureDataManager::_animationDatas fail!");
CCASSERT(_animationDatas, "create ArmatureDataManager::_animationDatas fail!");
_animationDatas->retain();
_textureDatas = Dictionary::create();
CCAssert(_textureDatas, "create ArmatureDataManager::_textureDatas fail!");
CCASSERT(_textureDatas, "create ArmatureDataManager::_textureDatas fail!");
_textureDatas->retain();
bRet = true;

View File

@ -217,7 +217,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent)
document.Parse(pFileContent);
tinyxml2::XMLElement *root = document.RootElement();
CCAssert(root, "XML error or XML is empty.");
CCASSERT(root, "XML error or XML is empty.");
root->QueryFloatAttribute(VERSION, &s_FlashToolVersion);
@ -308,7 +308,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
std::string name = boneXML->Attribute(A_NAME);
CCAssert(name.length() != 0, "");
CCASSERT(name.length() != 0, "");
BoneData *boneData = BoneData::create();

View File

@ -82,7 +82,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text
}
// check the format
CCAssert(format >= 0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
CCASSERT(format >= 0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
DictElement *pElement = NULL;
CCDICT_FOREACH(framesDict, pElement)

View File

@ -483,7 +483,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
else
{
CCLog("unsupported property name is %s", pPropName);
CCAssert(false, "unsupported property now");
CCASSERT(false, "unsupported property now");
}
}
}
@ -497,7 +497,7 @@ void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqPr
{
// Use base value (no animation)
Object *baseValue = getBaseValue(pNode, pSeqProp->getName());
CCAssert(baseValue, "No baseValue found for property");
CCASSERT(baseValue, "No baseValue found for property");
setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, fTweenDuration);
}
else
@ -735,7 +735,7 @@ void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuraiton)
void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration)
{
CCAssert(nSeqId != -1, "Sequence id couldn't be found");
CCASSERT(nSeqId != -1, "Sequence id couldn't be found");
mRootNode->stopAllActions();
@ -1029,7 +1029,7 @@ CCBRotateTo* CCBRotateTo::clone() const
CCBRotateTo* CCBRotateTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateTo");
CCASSERT(false, "reverse() is not supported in CCBRotateTo");
return nullptr;
}
@ -1109,7 +1109,7 @@ CCBRotateXTo* CCBRotateXTo::clone() const
CCBRotateXTo* CCBRotateXTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateXTo");
CCASSERT(false, "reverse() is not supported in CCBRotateXTo");
return nullptr;
}
@ -1170,7 +1170,7 @@ CCBRotateYTo* CCBRotateYTo::clone() const
CCBRotateYTo* CCBRotateYTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateXTo");
CCASSERT(false, "reverse() is not supported in CCBRotateXTo");
return nullptr;
}

View File

@ -155,7 +155,7 @@ CCBReader::~CCBReader() {
void CCBReader::setCCBRootPath(const char* pCCBRootPath)
{
CCAssert(pCCBRootPath != NULL, "");
CCASSERT(pCCBRootPath != NULL, "");
mCCBRootPath = pCCBRootPath;
}

View File

@ -45,7 +45,7 @@ Point getAbsolutePosition(const Point &pt, int nType, const Size &containerSize,
void setRelativeScale(Node *pNode, float fScaleX, float fScaleY, int nType, const char* pPropName)
{
CCAssert(pNode, "pNode should not be null");
CCASSERT(pNode, "pNode should not be null");
if (nType == kCCBScaleTypeMultiplyResolution)
{

View File

@ -60,37 +60,37 @@ ComAttribute* ComAttribute::create(void)
void ComAttribute::setInt(const char *key, int value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(Integer::create(value), key);
}
void ComAttribute::setDouble(const char *key, double value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(Double::create(value), key);
}
void ComAttribute::setFloat(const char *key, float value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(Float::create(value), key);
}
void ComAttribute::setBool(const char *key, bool value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(Bool::create(value), key);
}
void ComAttribute::setCString(const char *key, const char *value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(String::create(value), key);
}
void ComAttribute::setObject(const char *key, Object *value)
{
CCAssert(key != NULL, "Argument must be non-nil");
CCASSERT(key != NULL, "Argument must be non-nil");
_attributes->setObject(value, key);
}
@ -102,7 +102,7 @@ int ComAttribute::getInt(const char *key) const
if( Integer *obj=dynamic_cast<Integer*>(ret) )
return obj->getValue();
CCAssert(false, "Key found, type is not integer");
CCASSERT(false, "Key found, type is not integer");
}
// XXX: Should it throw an exception ?
@ -118,7 +118,7 @@ double ComAttribute::getDouble(const char *key) const
if( Double *obj=dynamic_cast<Double*>(ret) )
return obj->getValue();
CCAssert(false, "Key found, type is not double");
CCASSERT(false, "Key found, type is not double");
}
// XXX: Should it throw an exception ?
@ -134,7 +134,7 @@ float ComAttribute::getFloat(const char *key) const
if( Float *obj=dynamic_cast<Float*>(ret) )
return obj->getValue();
CCAssert(false, "Key found, type is not float");
CCASSERT(false, "Key found, type is not float");
}
// XXX: Should it throw an exception ?
@ -151,7 +151,7 @@ bool ComAttribute::getBool(const char *key) const
return boolobj->getValue();
if( String *strobj=dynamic_cast<String*>(ret) )
return strobj->boolValue();
CCAssert(false, "Key found, type is not Bool");
CCASSERT(false, "Key found, type is not Bool");
}
// XXX: Should it throw an exception ?
@ -167,7 +167,7 @@ const char* ComAttribute::getCString(const char *key) const
if( String *str=dynamic_cast<String*>(ret) )
return str->getCString();
CCAssert(false, "Key found, type is not CString");
CCASSERT(false, "Key found, type is not CString");
}
// XXX: Should it throw an exception ?

View File

@ -82,11 +82,11 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
{
if (Control::init())
{
CCAssert(node != NULL, "Label must not be nil.");
CCASSERT(node != NULL, "Label must not be nil.");
LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(node);
CCAssert(backgroundSprite != NULL, "Background sprite must not be nil.");
CCAssert(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL, "");
CCASSERT(backgroundSprite != NULL, "Background sprite must not be nil.");
CCASSERT(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL, "");
_parentInited = true;

Some files were not shown because too many files have changed in this diff Show More