clone() doesn't use copy constructor

... and other bug fixes
This commit is contained in:
Ricardo Quesada 2013-06-18 15:06:53 -07:00
parent d35cc3b0fa
commit 159ef1ec68
29 changed files with 664 additions and 272 deletions

View File

@ -115,9 +115,10 @@ bool CCSpeed::initWithAction(CCActionInterval *pAction, float fSpeed)
return true;
}
CCSpeed *CCSpeed::clone(void) const
CCSpeed *CCSpeed::clone() const
{
auto a = new CCSpeed(*this);
// no copy constructor
auto a = new CCSpeed();
a->initWithAction(_innerAction->clone(), _speed);
a->autorelease();
return a;
@ -202,9 +203,10 @@ CCFollow* CCFollow::create(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZ
return NULL;
}
CCFollow* CCFollow::clone(void) const
CCFollow* CCFollow::clone() const
{
auto a = new CCFollow(*this);
// no copy constructor
auto a = new CCFollow();
a->initWithTarget(_followedNode, _worldRect);
a->autorelease();
return a;

View File

@ -46,7 +46,7 @@ enum {
/**
@brief Base class for CCAction objects.
*/
class CC_DLL CCAction : public CCObject
class CC_DLL CCAction : public CCObject, public CCClonable
{
public:
CCAction(void);

View File

@ -47,14 +47,15 @@ void CCActionCamera::startWithTarget(CCNode *pTarget)
CCActionCamera* CCActionCamera::clone() const
{
auto a = new CCActionCamera(*this);
// no copy constructor
auto a = new CCActionCamera();
a->autorelease();
return a;
}
CCFiniteTimeAction * CCActionCamera::reverse() const
CCActionCamera * CCActionCamera::reverse() const
{
return CCReverseTime::create(const_cast<CCActionCamera*>(this));
return (CCActionCamera*)CCReverseTime::create(const_cast<CCActionCamera*>(this));
}
//
// CCOrbitCamera
@ -74,7 +75,8 @@ CCOrbitCamera * CCOrbitCamera::create(float t, float radius, float deltaRadius,
CCOrbitCamera* CCOrbitCamera::clone() const
{
auto a = new CCOrbitCamera(*this);
// no copy constructor
auto a = new CCOrbitCamera();
a->initWithDuration(_duration, _radius, _deltaRadius, _angleZ, _deltaAngleZ, _angleX, _deltaAngleX);
a->autorelease();
return a;

View File

@ -59,7 +59,7 @@ public:
// super methods
virtual void startWithTarget(CCNode *pTarget);
/** returns a new reversed action */
virtual CCFiniteTimeAction * reverse() const;
virtual CCActionCamera * reverse() const;
/** returns a new clone of the action */
virtual CCActionCamera *clone() const;
protected:

View File

@ -281,7 +281,8 @@ void CCCardinalSplineTo::startWithTarget(cocos2d::CCNode *pTarget)
CCCardinalSplineTo* CCCardinalSplineTo::clone() const
{
auto a = new CCCardinalSplineTo(*this);
// no copy constructor
auto a = new CCCardinalSplineTo();
a->initWithDuration(this->_duration, this->_points, this->_tension);
a->autorelease();
return a;
@ -447,7 +448,8 @@ void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget)
CCCardinalSplineBy* CCCardinalSplineBy::clone() const
{
auto a = new CCCardinalSplineBy(*this);
// no copy constructor
auto a = new CCCardinalSplineBy();
a->initWithDuration(this->_duration, (CCPointArray*)this->_points->copy()->autorelease(), this->_tension);
a->autorelease();
return a;
@ -486,12 +488,19 @@ bool CCCatmullRomTo::initWithDuration(float dt, cocos2d::CCPointArray *points)
CCCatmullRomTo* CCCatmullRomTo::clone() const
{
auto a = new CCCatmullRomTo(*this);
// no copy constructor
auto a = new CCCatmullRomTo();
a->initWithDuration(this->_duration, (CCPointArray*)this->_points->copy()->autorelease());
a->autorelease();
return a;
}
CCCatmullRomTo* CCCatmullRomTo::reverse() const
{
CCPointArray *pReverse = _points->reverse();
return CCCatmullRomTo::create(_duration, pReverse);
}
/* CCCatmullRomBy
*/
@ -526,11 +535,56 @@ bool CCCatmullRomBy::initWithDuration(float dt, cocos2d::CCPointArray *points)
CCCatmullRomBy* CCCatmullRomBy::clone() const
{
auto a = new CCCatmullRomBy(*this);
// no copy constructor
auto a = new CCCatmullRomBy();
a->initWithDuration(this->_duration, (CCPointArray*)this->_points->copy()->autorelease());
a->autorelease();
return a;
}
CCCatmullRomBy* CCCatmullRomBy::reverse() const
{
CCPointArray *copyConfig = (CCPointArray*)_points->copy();
//
// convert "absolutes" to "diffs"
//
CCPoint p = copyConfig->getControlPointAtIndex(0);
for (unsigned int i = 1; i < copyConfig->count(); ++i)
{
CCPoint current = copyConfig->getControlPointAtIndex(i);
CCPoint diff = ccpSub(current, p);
copyConfig->replaceControlPoint(diff, i);
p = current;
}
// convert to "diffs" to "reverse absolute"
CCPointArray *pReverse = copyConfig->reverse();
copyConfig->release();
// 1st element (which should be 0,0) should be here too
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
pReverse->removeControlPointAtIndex(pReverse->count()-1);
p = ccpNeg(p);
pReverse->insertControlPoint(p, 0);
for (unsigned int i = 1; i < pReverse->count(); ++i)
{
CCPoint current = pReverse->getControlPointAtIndex(i);
current = ccpNeg(current);
CCPoint abs = ccpAdd(current, p);
pReverse->replaceControlPoint(abs, i);
p = abs;
}
return CCCatmullRomBy::create(_duration, pReverse);
}
NS_CC_END;

View File

@ -192,6 +192,9 @@ public:
/** returns a new clone of the action */
virtual CCCatmullRomTo *clone() const;
/** returns a reversed copy of the action */
virtual CCCatmullRomTo *reverse() const;
};
/** An action that moves the target with a CatmullRom curve by a certain distance.
@ -211,6 +214,10 @@ public:
/** returns a new clone of the action */
virtual CCCatmullRomBy *clone() const;
/** returns a reversed copy of the action */
virtual CCCatmullRomBy *reverse() const;
};
/** Returns the Cardinal Spline position for a given set of control points, tension and time */

View File

@ -128,8 +128,9 @@ CCEaseIn* CCEaseIn::create(CCActionInterval *pAction, float fRate)
CCEaseIn* CCEaseIn::clone() const
{
auto a = new CCEaseIn(*this);
a->initWithAction((CCActionInterval*)_inner->clone(), _rate);
// no copy constructor
auto a = new CCEaseIn();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
@ -188,8 +189,9 @@ CCEaseOut* CCEaseOut::create(CCActionInterval *pAction, float fRate)
CCEaseOut* CCEaseOut::clone() const
{
auto a = new CCEaseOut(*this);
a->initWithAction((CCActionInterval*)_inner->clone(), _rate);
// no copy constructor
auto a = new CCEaseOut();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
@ -248,8 +250,9 @@ CCEaseInOut* CCEaseInOut::create(CCActionInterval *pAction, float fRate)
CCEaseInOut* CCEaseInOut::clone() const
{
auto a = new CCEaseInOut(*this);
a->initWithAction((CCActionInterval*)_inner->clone(), _rate);
// no copy constructor
auto a = new CCEaseInOut();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
@ -317,8 +320,9 @@ CCEaseExponentialIn* CCEaseExponentialIn::create(CCActionInterval* pAction)
CCEaseExponentialIn* CCEaseExponentialIn::clone() const
{
auto a = new CCEaseExponentialIn(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseExponentialIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -377,8 +381,9 @@ CCEaseExponentialOut* CCEaseExponentialOut::create(CCActionInterval* pAction)
CCEaseExponentialOut* CCEaseExponentialOut::clone() const
{
auto a = new CCEaseExponentialOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseExponentialOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -438,8 +443,9 @@ CCEaseExponentialInOut* CCEaseExponentialInOut::create(CCActionInterval *pAction
CCEaseExponentialInOut* CCEaseExponentialInOut::clone() const
{
auto a = new CCEaseExponentialInOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseExponentialInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -509,8 +515,9 @@ CCEaseSineIn* CCEaseSineIn::create(CCActionInterval* pAction)
CCEaseSineIn* CCEaseSineIn::clone() const
{
auto a = new CCEaseSineIn(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseSineIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -570,8 +577,9 @@ CCEaseSineOut* CCEaseSineOut::create(CCActionInterval* pAction)
CCEaseSineOut* CCEaseSineOut::clone() const
{
auto a = new CCEaseSineOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseSineOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -631,8 +639,9 @@ CCEaseSineInOut* CCEaseSineInOut::create(CCActionInterval* pAction)
CCEaseSineInOut* CCEaseSineInOut::clone() const
{
auto a = new CCEaseSineInOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseSineInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -712,8 +721,9 @@ CCEaseElasticIn* CCEaseElasticIn::create(CCActionInterval *pAction, float fPerio
CCEaseElasticIn* CCEaseElasticIn::clone() const
{
auto a = new CCEaseElasticIn(*this);
a->initWithAction((CCActionInterval *)_inner->clone(), _period);
// no copy constructor
auto a = new CCEaseElasticIn();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
@ -790,8 +800,9 @@ CCEaseElasticOut* CCEaseElasticOut::create(CCActionInterval *pAction, float fPer
CCEaseElasticOut* CCEaseElasticOut::clone() const
{
auto a = new CCEaseElasticOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone(), _period);
// no copy constructor
auto a = new CCEaseElasticOut();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
@ -867,8 +878,9 @@ CCEaseElasticInOut* CCEaseElasticInOut::create(CCActionInterval *pAction, float
CCEaseElasticInOut* CCEaseElasticInOut::clone() const
{
auto a = new CCEaseElasticInOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone(), _period);
// no copy constructor
auto a = new CCEaseElasticInOut();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
@ -980,8 +992,9 @@ CCEaseBounceIn* CCEaseBounceIn::create(CCActionInterval* pAction)
CCEaseBounceIn* CCEaseBounceIn::clone() const
{
auto a = new CCEaseBounceIn(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBounceIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -1042,8 +1055,9 @@ CCEaseBounceOut* CCEaseBounceOut::create(CCActionInterval* pAction)
CCEaseBounceOut* CCEaseBounceOut::clone() const
{
auto a = new CCEaseBounceOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBounceOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -1104,8 +1118,9 @@ CCEaseBounceInOut* CCEaseBounceInOut::create(CCActionInterval* pAction)
CCEaseBounceInOut* CCEaseBounceInOut::clone() const
{
auto a = new CCEaseBounceInOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBounceInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -1176,8 +1191,9 @@ CCEaseBackIn* CCEaseBackIn::create(CCActionInterval *pAction)
CCEaseBackIn* CCEaseBackIn::clone() const
{
auto a = new CCEaseBackIn(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBackIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -1238,8 +1254,9 @@ CCEaseBackOut* CCEaseBackOut::create(CCActionInterval* pAction)
CCEaseBackOut* CCEaseBackOut::clone() const
{
auto a = new CCEaseBackOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBackOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
@ -1302,8 +1319,9 @@ CCEaseBackInOut* CCEaseBackInOut::create(CCActionInterval* pAction)
CCEaseBackInOut* CCEaseBackInOut::clone() const
{
auto a = new CCEaseBackInOut(*this);
a->initWithAction((CCActionInterval *)_inner->clone());
// no copy constructor
auto a = new CCEaseBackInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}

View File

@ -174,7 +174,8 @@ bool CCAccelDeccelAmplitude::initWithAction(CCAction *pAction, float duration)
CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::clone() const
{
auto a = new CCAccelDeccelAmplitude(*this);
// no copy constructor
auto a = new CCAccelDeccelAmplitude();
a->initWithAction(_other->clone(), _rate);
a->autorelease();
return a;
@ -245,7 +246,8 @@ bool CCAccelAmplitude::initWithAction(CCAction *pAction, float duration)
CCAccelAmplitude* CCAccelAmplitude::clone() const
{
auto a = new CCAccelAmplitude(*this);
// no copy constructor
auto a = new CCAccelAmplitude();
a->initWithAction(_other->clone(), _duration);
a->autorelease();
return a;
@ -326,7 +328,8 @@ void CCDeccelAmplitude::update(float time)
CCDeccelAmplitude* CCDeccelAmplitude::clone() const
{
auto a = new CCDeccelAmplitude(*this);
// no copy constructor
auto a = new CCDeccelAmplitude();
a->initWithAction(_other->clone(), _duration);
a->autorelease();
return a;

View File

@ -64,6 +64,15 @@ bool CCWaves3D::initWithDuration(float duration, const CCSize& gridSize, unsigne
return false;
}
CCWaves3D* CCWaves3D::clone() const
{
// no copy constructor
auto a = new CCWaves3D();
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
a->autorelease();
return a;
}
CCObject* CCWaves3D::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -144,7 +153,8 @@ bool CCFlipX3D::initWithSize(const CCSize& gridSize, float duration)
CCFlipX3D* CCFlipX3D::clone() const
{
auto a = new CCFlipX3D(*this);
// no copy constructor
auto a = new CCFlipX3D();
a->initWithSize(_gridSize, _duration);
a->autorelease();
return a;
@ -384,6 +394,15 @@ bool CCLens3D::initWithDuration(float duration, const CCSize& gridSize, const CC
return false;
}
CCLens3D* CCLens3D::clone() const
{
// no copy constructor
auto a = new CCLens3D();
a->initWithDuration(_duration, _gridSize, _position, _radius);
a->autorelease();
return a;
}
CCObject* CCLens3D::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -501,6 +520,16 @@ void CCRipple3D::setPosition(const CCPoint& position)
_position = position;
}
CCRipple3D* CCRipple3D::clone() const
{
// no copy constructor
auto a = new CCRipple3D();
a->initWithDuration(_duration, _gridSize, _position, _radius, _waves, _amplitude);
a->autorelease();
return a;
}
CCObject* CCRipple3D::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -582,6 +611,15 @@ bool CCShaky3D::initWithDuration(float duration, const CCSize& gridSize, int ran
return false;
}
CCShaky3D* CCShaky3D::clone() const
{
// no copy constructor
auto a = new CCShaky3D();
a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ);
a->autorelease();
return a;
}
CCObject* CCShaky3D::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -662,6 +700,15 @@ bool CCLiquid::initWithDuration(float duration, const CCSize& gridSize, unsigned
return false;
}
CCLiquid* CCLiquid::clone() const
{
// no copy constructor
auto a = new CCLiquid();
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
a->autorelease();
return a;
}
CCObject* CCLiquid::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -738,6 +785,15 @@ bool CCWaves::initWithDuration(float duration, const CCSize& gridSize, unsigned
return false;
}
CCWaves* CCWaves::clone() const
{
// no copy constructor
auto a = new CCWaves();
a->initWithDuration(_duration, _gridSize, _waves, _amplitude, _horizontal, _vertical);
a->autorelease();
return a;
}
CCObject* CCWaves::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -827,6 +883,15 @@ void CCTwirl::setPosition(const CCPoint& position)
_position = position;
}
CCTwirl *CCTwirl::clone() const
{
// no copy constructor
auto a = new CCTwirl();
a->initWithDuration(_duration, _gridSize, _position, _twirls, _amplitude);
a->autorelease();
return a;
}
CCObject* CCTwirl::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;

View File

@ -75,7 +75,8 @@ CCActionInstant* CCShow::reverse() const
CCShow * CCShow::clone() const
{
auto a = new CCShow(*this);
// no copy constructor
auto a = new CCShow();
a->autorelease();
return a;
}
@ -122,7 +123,8 @@ CCActionInstant *CCHide::reverse() const
CCHide * CCHide::clone() const
{
auto a = new CCHide(*this);
// no copy constructor
auto a = new CCHide();
a->autorelease();
return a;
}
@ -171,7 +173,8 @@ CCToggleVisibility * CCToggleVisibility::reverse() const
CCToggleVisibility * CCToggleVisibility::clone() const
{
auto a = new CCToggleVisibility(*this);
// no copy constructor
auto a = new CCToggleVisibility();
a->autorelease();
return a;
}
@ -224,7 +227,8 @@ CCRemoveSelf *CCRemoveSelf::reverse() const
CCRemoveSelf * CCRemoveSelf::clone() const
{
auto a = new CCRemoveSelf(*this);
// no copy constructor
auto a = new CCRemoveSelf();
a->init(_isNeedCleanUp);
a->autorelease();
return a;
@ -281,7 +285,8 @@ CCFlipX* CCFlipX::reverse() const
CCFlipX * CCFlipX::clone() const
{
auto a = new CCFlipX(*this);
// no copy constructor
auto a = new CCFlipX();
a->initWithFlipX(_flipX);
a->autorelease();
return a;
@ -338,7 +343,8 @@ CCFlipY* CCFlipY::reverse() const
CCFlipY * CCFlipY::clone() const
{
auto a = new CCFlipY(*this);
// no copy constructor
auto a = new CCFlipY();
a->initWithFlipY(_flipY);
a->autorelease();
return a;
@ -385,7 +391,8 @@ bool CCPlace::initWithPosition(const CCPoint& pos) {
CCPlace * CCPlace::clone() const
{
auto a = new CCPlace(*this);
// no copy constructor
auto a = new CCPlace();
a->initWithPosition(_position);
a->autorelease();
return a;
@ -496,7 +503,8 @@ CCCallFunc::~CCCallFunc(void)
CCCallFunc * CCCallFunc::clone() const
{
auto a = new CCCallFunc(*this);
// no copy constructor
auto a = new CCCallFunc();
if( _selectorTarget) {
a->initWithTarget(_selectorTarget);
a->_callFunc = _callFunc;
@ -609,7 +617,8 @@ bool CCCallFuncN::initWithTarget(CCObject* pSelectorTarget,
CCCallFuncN * CCCallFuncN::clone() const
{
auto a = new CCCallFuncN(*this);
// no copy constructor
auto a = new CCCallFuncN();
a->initWithTarget(_selectorTarget, _callFuncN);
a->autorelease();
return a;
@ -663,7 +672,8 @@ bool CCCallFuncND::initWithTarget(CCObject* pSelectorTarget,
CCCallFuncND * CCCallFuncND::clone() const
{
auto a = new CCCallFuncND(*this);
// no copy constructor
auto a = new CCCallFuncND();
a->initWithTarget(_selectorTarget, _callFuncND, _data);
a->autorelease();
return a;
@ -738,7 +748,8 @@ bool CCCallFuncO::initWithTarget(CCObject* pSelectorTarget,
CCCallFuncO * CCCallFuncO::clone() const
{
auto a = new CCCallFuncO(*this);
// no copy constructor
auto a = new CCCallFuncO();
a->initWithTarget(_selectorTarget, _callFuncO, _object);
a->autorelease();
return a;

View File

@ -58,7 +58,8 @@ ExtraAction* ExtraAction::create()
}
ExtraAction* ExtraAction::clone(void) const
{
auto a = new ExtraAction(*this);
// no copy constructor
auto a = new ExtraAction();
a->autorelease();
return a;
}
@ -154,12 +155,6 @@ void CCActionInterval::startWithTarget(CCNode *pTarget)
_firstTick = true;
}
CCActionInterval* CCActionInterval::reverse(void)
{
CCAssert(false, "CCIntervalAction: reverse not implemented.");
return NULL;
}
//
// Sequence
//
@ -259,7 +254,8 @@ bool CCSequence::initWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTime
CCSequence* CCSequence::clone(void) const
{
auto a = new CCSequence(*this);
// no copy constructor
auto a = new CCSequence();
a->initWithTwoActions((CCFiniteTimeAction*)(_actions[0]->clone()),
(CCFiniteTimeAction*)(_actions[1]->clone())
);
@ -284,8 +280,7 @@ CCObject* CCSequence::copyWithZone(CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithTwoActions((CCFiniteTimeAction*)(_actions[0]->copy()->autorelease()),
(CCFiniteTimeAction*)(_actions[1]->copy()->autorelease()));
pCopy->initWithTwoActions(_actions[0]->clone(), _actions[1]->clone());
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -421,7 +416,8 @@ bool CCRepeat::initWithAction(CCFiniteTimeAction *pAction, unsigned int times)
CCRepeat* CCRepeat::clone(void) const
{
auto a = new CCRepeat(*this);
// no copy constructor
auto a = new CCRepeat();
a->initWithAction((CCFiniteTimeAction*)_innerAction->clone(), _times );
a->autorelease();
return a;
@ -446,7 +442,7 @@ CCObject* CCRepeat::copyWithZone(CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithAction((CCFiniteTimeAction*)(_innerAction->copy()->autorelease()), _times);
pCopy->initWithAction(_innerAction->clone(), _times);
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -555,7 +551,8 @@ bool CCRepeatForever::initWithAction(CCActionInterval *pAction)
CCRepeatForever *CCRepeatForever::clone(void) const
{
auto a = new CCRepeatForever(*this);
// no copy constructor
auto a = new CCRepeatForever();
a->initWithAction((CCActionInterval*)_innerAction->clone());
a->autorelease();
return a;
@ -576,7 +573,7 @@ CCObject* CCRepeatForever::copyWithZone(CCZone *pZone)
}
CCActionInterval::copyWithZone(pZone);
// win32 : use the _other's copy object.
pRet->initWithAction((CCActionInterval*)(_innerAction->copy()->autorelease()));
pRet->initWithAction(_innerAction->clone());
CC_SAFE_DELETE(pNewZone);
return pRet;
}
@ -725,9 +722,9 @@ bool CCSpawn:: initWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeActi
CCSpawn* CCSpawn::clone(void) const
{
auto a = new CCSpawn(*this);
a->initWithTwoActions((CCFiniteTimeAction*)_one->clone(),
(CCFiniteTimeAction*)_two->clone());
// no copy constructor
auto a = new CCSpawn();
a->initWithTwoActions(_one->clone(), _two->clone());
a->autorelease();
return a;
@ -751,8 +748,7 @@ CCObject* CCSpawn::copyWithZone(CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithTwoActions((CCFiniteTimeAction*)(_one->copy()->autorelease()),
(CCFiniteTimeAction*)(_two->copy()->autorelease()));
pCopy->initWithTwoActions(_one->clone(), _two->clone());
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -843,7 +839,8 @@ bool CCRotateTo::initWithDuration(float fDuration, float fDeltaAngleX, float fDe
CCRotateTo* CCRotateTo::clone(void) const
{
auto a = new CCRotateTo(*this);
// no copy constructor
auto a = new CCRotateTo();
a->initWithDuration(_duration, _dstAngleX, _dstAngleY);
a->autorelease();
return a;
@ -984,7 +981,8 @@ bool CCRotateBy::initWithDuration(float fDuration, float fDeltaAngleX, float fDe
CCRotateBy* CCRotateBy::clone(void) const
{
auto a = new CCRotateBy(*this);
// no copy constructor
auto a = new CCRotateBy();
a->initWithDuration(_duration, _angleX, _angleY);
a->autorelease();
return a;
@ -1061,7 +1059,8 @@ bool CCMoveBy::initWithDuration(float duration, const CCPoint& deltaPosition)
CCMoveBy* CCMoveBy::clone(void) const
{
auto a = new CCMoveBy(*this);
// no copy constructor
auto a = new CCMoveBy();
a->initWithDuration(_duration, _positionDelta);
a->autorelease();
return a;
@ -1145,7 +1144,8 @@ bool CCMoveTo::initWithDuration(float duration, const CCPoint& position)
CCMoveTo* CCMoveTo::clone(void) const
{
auto a = new CCMoveTo(*this);
// no copy constructor
auto a = new CCMoveTo();
a->initWithDuration(_duration, _endPosition);
a->autorelease();
return a;
@ -1219,12 +1219,19 @@ bool CCSkewTo::initWithDuration(float t, float sx, float sy)
CCSkewTo* CCSkewTo::clone(void) const
{
auto a = new CCSkewTo(*this);
// no copy constructor
auto a = new CCSkewTo();
a->initWithDuration(_duration, _endSkewX, _endSkewY);
a->autorelease();
return a;
}
CCSkewTo* CCSkewTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCSkewTo");
return nullptr;
}
CCObject* CCSkewTo::copyWithZone(CCZone* pZone)
{
CCZone* pNewZone = NULL;
@ -1338,7 +1345,8 @@ CCSkewBy* CCSkewBy::create(float t, float sx, float sy)
CCSkewBy * CCSkewBy::clone() const
{
auto a = new CCSkewBy(*this);
// no copy constructor
auto a = new CCSkewBy();
a->initWithDuration(_duration, _skewX, _skewY);
a->autorelease();
return a;
@ -1402,7 +1410,8 @@ bool CCJumpBy::initWithDuration(float duration, const CCPoint& position, float h
CCJumpBy* CCJumpBy::clone(void) const
{
auto a = new CCJumpBy(*this);
// no copy constructor
auto a = new CCJumpBy();
a->initWithDuration(_duration, _delta, _height, _jumps);
a->autorelease();
return a;
@ -1484,12 +1493,19 @@ CCJumpTo* CCJumpTo::create(float duration, const CCPoint& position, float height
CCJumpTo* CCJumpTo::clone(void) const
{
auto a = new CCJumpTo(*this);
// no copy constructor
auto a = new CCJumpTo();
a->initWithDuration(_duration, _delta, _height, _jumps);
a->autorelease();
return a;
}
CCJumpTo* CCJumpTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCJumpTo");
return nullptr;
}
CCObject* CCJumpTo::copyWithZone(CCZone* pZone)
{
CCZone* pNewZone = NULL;
@ -1563,7 +1579,8 @@ void CCBezierBy::startWithTarget(CCNode *pTarget)
CCBezierBy* CCBezierBy::clone(void) const
{
auto a = new CCBezierBy(*this);
// no copy constructor
auto a = new CCBezierBy();
a->initWithDuration(_duration, _config);
a->autorelease();
return a;
@ -1663,7 +1680,8 @@ bool CCBezierTo::initWithDuration(float t, const ccBezierConfig &c)
CCBezierTo* CCBezierTo::clone(void) const
{
auto a = new CCBezierTo(*this);
// no copy constructor
auto a = new CCBezierTo();
a->initWithDuration(_duration, _config);
a->autorelease();
return a;
@ -1719,6 +1737,15 @@ CCScaleTo* CCScaleTo::create(float duration, float s)
return pScaleTo;
}
CCScaleTo* CCScaleTo::create(float duration, float sx, float sy)
{
CCScaleTo *pScaleTo = new CCScaleTo();
pScaleTo->initWithDuration(duration, sx, sy);
pScaleTo->autorelease();
return pScaleTo;
}
bool CCScaleTo::initWithDuration(float duration, float s)
{
if (CCActionInterval::initWithDuration(duration))
@ -1732,15 +1759,6 @@ bool CCScaleTo::initWithDuration(float duration, float s)
return false;
}
CCScaleTo* CCScaleTo::create(float duration, float sx, float sy)
{
CCScaleTo *pScaleTo = new CCScaleTo();
pScaleTo->initWithDuration(duration, sx, sy);
pScaleTo->autorelease();
return pScaleTo;
}
bool CCScaleTo::initWithDuration(float duration, float sx, float sy)
{
if (CCActionInterval::initWithDuration(duration))
@ -1756,12 +1774,20 @@ bool CCScaleTo::initWithDuration(float duration, float sx, float sy)
CCScaleTo* CCScaleTo::clone(void) const
{
auto a = new CCScaleTo(*this);
// no copy constructor
auto a = new CCScaleTo();
a->initWithDuration(_duration, _endScaleX, _endScaleY);
a->autorelease();
return a;
}
CCScaleTo* CCScaleTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCScaleTo");
return nullptr;
}
CCObject* CCScaleTo::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -1828,7 +1854,8 @@ CCScaleBy* CCScaleBy::create(float duration, float sx, float sy)
CCScaleBy* CCScaleBy::clone(void) const
{
auto a = new CCScaleBy(*this);
// no copy constructor
auto a = new CCScaleBy();
a->initWithDuration(_duration, _endScaleX, _endScaleY);
a->autorelease();
return a;
@ -1908,7 +1935,8 @@ void CCBlink::startWithTarget(CCNode *pTarget)
CCBlink* CCBlink::clone(void) const
{
auto a = new CCBlink(*this);
// no copy constructor
auto a = new CCBlink();
a->initWithDuration(_duration, (unsigned int)_times);
a->autorelease();
return a;
@ -1967,9 +1995,10 @@ CCFadeIn* CCFadeIn::create(float d)
return pAction;
}
CCFadeIn* CCFadeIn::clone(void) const
CCFadeIn* CCFadeIn::clone() const
{
auto a = new CCFadeIn(*this);
// no copy constructor
auto a = new CCFadeIn();
a->autorelease();
return a;
}
@ -2025,9 +2054,10 @@ CCFadeOut* CCFadeOut::create(float d)
return pAction;
}
CCFadeOut* CCFadeOut::clone(void) const
CCFadeOut* CCFadeOut::clone() const
{
auto a = new CCFadeOut(*this);
// no copy constructor
auto a = new CCFadeOut();
a->autorelease();
return a;
}
@ -2093,14 +2123,21 @@ bool CCFadeTo::initWithDuration(float duration, GLubyte opacity)
return false;
}
CCFadeTo* CCFadeTo::clone(void) const
CCFadeTo* CCFadeTo::clone() const
{
auto a = new CCFadeTo(*this);
// no copy constructor
auto a = new CCFadeTo();
a->initWithDuration(_duration, _toOpacity);
a->autorelease();
return a;
}
CCFadeTo* CCFadeTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCFadeTo");
return nullptr;
}
CCObject* CCFadeTo::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -2169,14 +2206,21 @@ bool CCTintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLub
return false;
}
CCTintTo* CCTintTo::clone(void) const
CCTintTo* CCTintTo::clone() const
{
auto a = new CCTintTo(*this);
// no copy constructor
auto a = new CCTintTo();
a->initWithDuration(_duration, _to.r, _to.g, _to.b);
a->autorelease();
return a;
}
CCTintTo* CCTintTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCTintTo");
return nullptr;
}
CCObject* CCTintTo::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -2249,9 +2293,10 @@ bool CCTintBy::initWithDuration(float duration, GLshort deltaRed, GLshort deltaG
return false;
}
CCTintBy* CCTintBy::clone(void) const
CCTintBy* CCTintBy::clone() const
{
auto a = new CCTintBy(*this);
// no copy constructor
auto a = new CCTintBy();
a->initWithDuration(_duration, (GLubyte)_deltaR, (GLubyte)_deltaG, (GLubyte)_deltaB);
a->autorelease();
return a;
@ -2323,9 +2368,10 @@ CCDelayTime* CCDelayTime::create(float d)
return pAction;
}
CCDelayTime* CCDelayTime::clone(void) const
CCDelayTime* CCDelayTime::clone() const
{
auto a = new CCDelayTime(*this);
// no copy constructor
auto a = new CCDelayTime();
a->autorelease();
return a;
}
@ -2396,9 +2442,10 @@ bool CCReverseTime::initWithAction(CCFiniteTimeAction *pAction)
return false;
}
CCReverseTime* CCReverseTime::clone(void) const
CCReverseTime* CCReverseTime::clone() const
{
auto a = new CCReverseTime(*this);
// no copy constructor
auto a = new CCReverseTime();
a->initWithAction( _other->clone() );
a->autorelease();
return a;
@ -2421,7 +2468,7 @@ CCObject* CCReverseTime::copyWithZone(CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithAction((CCFiniteTimeAction*)(_other->copy()->autorelease()));
pCopy->initWithAction(_other->clone());
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -2457,9 +2504,9 @@ void CCReverseTime::update(float time)
}
}
CCFiniteTimeAction* CCReverseTime::reverse() const
CCReverseTime* CCReverseTime::reverse() const
{
return _other->clone();
return (CCReverseTime*)_other->clone();
}
//
@ -2508,10 +2555,11 @@ bool CCAnimate::initWithAnimation(CCAnimation *pAnimation)
return false;
}
CCAnimate* CCAnimate::clone(void) const
CCAnimate* CCAnimate::clone() const
{
auto a = new CCAnimate(*this);
a->initWithAnimation((CCAnimation*)_animation->copy()->autorelease());
// no copy constructor
auto a = new CCAnimate();
a->initWithAnimation(_animation->clone());
a->autorelease();
return a;
}
@ -2533,7 +2581,7 @@ CCObject* CCAnimate::copyWithZone(CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithAnimation((CCAnimation*)_animation->copy()->autorelease());
pCopy->initWithAnimation(_animation->clone());
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -2643,13 +2691,13 @@ CCAnimate* CCAnimate::reverse() const
break;
}
pNewArray->addObject((CCAnimationFrame*)(pElement->copy()->autorelease()));
pNewArray->addObject(pElement->clone());
}
}
CCAnimation *newAnim = CCAnimation::create(pNewArray, _animation->getDelayPerUnit(), _animation->getLoops());
newAnim->setRestoreOriginalFrame(_animation->getRestoreOriginalFrame());
return create(newAnim);
return CCAnimate::create(newAnim);
}
// CCTargetedAction
@ -2689,11 +2737,12 @@ bool CCTargetedAction::initWithTarget(CCNode* pTarget, CCFiniteTimeAction* pActi
return false;
}
CCTargetedAction* CCTargetedAction::clone(void) const
CCTargetedAction* CCTargetedAction::clone() const
{
auto a = new CCTargetedAction(*this);
// no copy constructor
auto a = new CCTargetedAction();
// win32 : use the _other's copy object.
a->initWithTarget(_forcedTarget, (CCFiniteTimeAction*)_action->clone());
a->initWithTarget(_forcedTarget, _action->clone());
a->autorelease();
return a;
}
@ -2719,7 +2768,7 @@ CCObject* CCTargetedAction::copyWithZone(CCZone* pZone)
}
CCActionInterval::copyWithZone(pZone);
// win32 : use the _other's copy object.
pRet->initWithTarget(_forcedTarget, (CCFiniteTimeAction*)_action->copy()->autorelease());
pRet->initWithTarget(_forcedTarget, _action->clone());
CC_SAFE_DELETE(pNewZone);
return pRet;
}

View File

@ -72,8 +72,9 @@ public:
virtual void step(float dt);
virtual void startWithTarget(CCNode *pTarget);
/** returns a reversed action */
virtual CCActionInterval* reverse(void);
virtual CCActionInterval* reverse() const = 0;
virtual CCActionInterval *clone() const = 0;
@ -796,7 +797,7 @@ public:
bool initWithAction(CCFiniteTimeAction *pAction);
/** returns a new reversed action */
virtual CCFiniteTimeAction* reverse() const;
virtual CCReverseTime* reverse() const;
/** returns a new clone of the action */
virtual CCReverseTime* clone() const;
virtual CCObject* copyWithZone(CCZone* pZone);

View File

@ -47,6 +47,15 @@ CCPageTurn3D* CCPageTurn3D::create(float duration, const CCSize& gridSize)
return pAction;
}
CCPageTurn3D *CCPageTurn3D::clone() const
{
// no copy constructor
auto a = new CCPageTurn3D();
a->initWithDuration(_duration, _gridSize);
a->autorelease();
return a;
}
/*
* Update each tick
* Time is the percentage of the way through the duration

View File

@ -49,9 +49,6 @@ public:
/** returns a new clone of the action */
virtual CCPageTurn3D* clone() const;
/** returns a a new reversed action */
virtual CCPageTurn3D* reverse() const;
virtual void update(float time);
public:

View File

@ -53,6 +53,21 @@ bool CCProgressTo::initWithDuration(float duration, float fPercent)
return false;
}
CCProgressTo* CCProgressTo::clone() const
{
// no copy constructor
auto a = new CCProgressTo();
a->initWithDuration(_duration, _to);
a->autorelease();
return a;
}
CCProgressTo* CCProgressTo::reverse() const
{
CCAssert(false, "reverse() not supported in CCProgressTo");
return nullptr;
}
CCObject* CCProgressTo::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;
@ -118,6 +133,15 @@ bool CCProgressFromTo::initWithDuration(float duration, float fFromPercentage, f
return false;
}
CCProgressFromTo* CCProgressFromTo::clone() const
{
// no copy constructor
auto a = new CCProgressFromTo();
a->initWithDuration(_duration, _from, _to);
a->autorelease();
return a;
}
CCObject* CCProgressFromTo::copyWithZone(CCZone *pZone)
{
CCZone* pNewZone = NULL;

View File

@ -75,7 +75,8 @@ bool CCShakyTiles3D::initWithDuration(float duration, const CCSize& gridSize, in
CCShakyTiles3D* CCShakyTiles3D::clone() const
{
auto a = new CCShakyTiles3D(*this);
// no copy constructor
auto a = new CCShakyTiles3D();
a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ);
a->autorelease();
return a;
@ -177,7 +178,8 @@ bool CCShatteredTiles3D::initWithDuration(float duration, const CCSize& gridSize
CCShatteredTiles3D* CCShatteredTiles3D::clone() const
{
auto a = new CCShatteredTiles3D(*this);
// no copy constructor
auto a = new CCShatteredTiles3D();
a->initWithDuration(_duration, _gridSize, _randrange, _shatterZ);
a->autorelease();
return a;
@ -284,7 +286,8 @@ bool CCShuffleTiles::initWithDuration(float duration, const CCSize& gridSize, un
CCShuffleTiles* CCShuffleTiles::clone() const
{
auto a = new CCShuffleTiles(*this);
// no copy constructor
auto a = new CCShuffleTiles();
a->initWithDuration(_duration, _gridSize, _seed);
a->autorelease();
return a;
@ -442,7 +445,8 @@ CCFadeOutTRTiles* CCFadeOutTRTiles::create(float duration, const CCSize& gridSiz
CCFadeOutTRTiles* CCFadeOutTRTiles::clone() const
{
auto a = new CCFadeOutTRTiles(*this);
// no copy constructor
auto a = new CCFadeOutTRTiles();
a->initWithDuration(_duration, _gridSize);
a->autorelease();
return a;
@ -539,7 +543,8 @@ CCFadeOutBLTiles* CCFadeOutBLTiles::create(float duration, const CCSize& gridSiz
CCFadeOutBLTiles* CCFadeOutBLTiles::clone() const
{
auto a = new CCFadeOutBLTiles(*this);
// no copy constructor
auto a = new CCFadeOutBLTiles();
a->initWithDuration(_duration, _gridSize);
a->autorelease();
return a;
@ -579,7 +584,8 @@ CCFadeOutUpTiles* CCFadeOutUpTiles::create(float duration, const CCSize& gridSiz
CCFadeOutUpTiles* CCFadeOutUpTiles::clone() const
{
auto a = new CCFadeOutUpTiles(*this);
// no copy constructor
auto a = new CCFadeOutUpTiles();
a->initWithDuration(_duration, _gridSize);
a->autorelease();
return a;
@ -632,7 +638,8 @@ CCFadeOutDownTiles* CCFadeOutDownTiles::create(float duration, const CCSize& gri
CCFadeOutDownTiles* CCFadeOutDownTiles::clone() const
{
auto a = new CCFadeOutDownTiles(*this);
// no copy constructor
auto a = new CCFadeOutDownTiles();
a->initWithDuration(_duration, _gridSize);
a->autorelease();
return a;
@ -699,7 +706,8 @@ bool CCTurnOffTiles::initWithDuration(float duration, const CCSize& gridSize, un
CCTurnOffTiles* CCTurnOffTiles::clone() const
{
auto a = new CCTurnOffTiles(*this);
// no copy constructor
auto a = new CCTurnOffTiles();
a->initWithDuration(_duration, _gridSize, _seed );
a->autorelease();
return a;
@ -838,7 +846,8 @@ bool CCWavesTiles3D::initWithDuration(float duration, const CCSize& gridSize, un
CCWavesTiles3D* CCWavesTiles3D::clone() const
{
auto a = new CCWavesTiles3D(*this);
// no copy constructor
auto a = new CCWavesTiles3D();
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
a->autorelease();
return a;
@ -924,7 +933,8 @@ bool CCJumpTiles3D::initWithDuration(float duration, const CCSize& gridSize, uns
CCJumpTiles3D* CCJumpTiles3D::clone() const
{
auto a = new CCJumpTiles3D(*this);
// no copy constructor
auto a = new CCJumpTiles3D();
a->initWithDuration(_duration, _gridSize, _jumps, _amplitude);
a->autorelease();
return a;
@ -1014,7 +1024,8 @@ bool CCSplitRows::initWithDuration(float duration, unsigned int nRows)
CCSplitRows* CCSplitRows::clone() const
{
auto a = new CCSplitRows(*this);
// no copy constructor
auto a = new CCSplitRows();
a->initWithDuration(_duration, _rows);
a->autorelease();
return a;
@ -1100,7 +1111,8 @@ bool CCSplitCols::initWithDuration(float duration, unsigned int nCols)
CCSplitCols* CCSplitCols::clone() const
{
auto a = new CCSplitCols(*this);
// no copy constructor
auto a = new CCSplitCols();
a->initWithDuration(_duration, _cols);
a->autorelease();
return a;

View File

@ -56,7 +56,8 @@ bool CCActionTween::initWithDuration(float aDuration, const char* key, float fro
CCActionTween *CCActionTween::clone() const
{
auto a = new CCActionTween(*this);
// no copy constructor
auto a = new CCActionTween();
a->initWithDuration(_duration, _key.c_str(), _from, _to);
a->autorelease();
return a;

View File

@ -50,6 +50,15 @@ public:
};
/** Interface that defines how to clone an object */
class CC_DLL CCClonable
{
public:
/** returns a copy of the object */
virtual CCClonable* clone() const = 0;
virtual ~CCClonable() {};
};
class CC_DLL CCObject : public CCCopying
{
public:

View File

@ -57,6 +57,18 @@ CCAnimationFrame::~CCAnimationFrame()
CC_SAFE_RELEASE(_userInfo);
}
CCAnimationFrame* CCAnimationFrame::clone() const
{
// no copy constructor
auto frame = new CCAnimationFrame();
frame->initWithSpriteFrame(_spriteFrame->clone(),
_delayUnits,
_userInfo != NULL ? (CCDictionary*)_userInfo->copy()->autorelease() : NULL);
frame->autorelease();
return frame;
}
CCObject* CCAnimationFrame::copyWithZone(CCZone* pZone)
{
CCZone* pNewZone = NULL;
@ -205,6 +217,16 @@ float CCAnimation::getDuration(void) const
return _totalDelayUnits * _delayPerUnit;
}
CCAnimation* CCAnimation::clone() const
{
// no copy constructor
auto a = new CCAnimation();
a->initWithAnimationFrames(_frames, _delayPerUnit, _loops);
a->setRestoreOriginalFrame(_restoreOriginalFrame);
a->autorelease();
return a;
}
CCObject* CCAnimation::copyWithZone(CCZone* pZone)
{
CCZone* pNewZone = NULL;

View File

@ -52,7 +52,7 @@ class CCSpriteFrame;
@since v2.0
*/
class CC_DLL CCAnimationFrame : public CCObject
class CC_DLL CCAnimationFrame : public CCObject, public CCClonable
{
public:
CCAnimationFrame();
@ -60,7 +60,10 @@ public:
virtual CCObject* copyWithZone(CCZone* pZone);
/** initializes the animation frame with a spriteframe, number of delay units and a notification user info */
bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo);
/** returns a copy of the CCAnimationFrame */
virtual CCAnimationFrame *clone() const;
/** CCSpriteFrameName to be used */
CC_SYNTHESIZE_RETAIN(CCSpriteFrame*, _spriteFrame, SpriteFrame)
@ -82,7 +85,7 @@ You can animate a CCAnimation object by using the CCAnimate action. Example:
[sprite runAction:[CCAnimate actionWithAnimation:animation]];
*/
class CC_DLL CCAnimation : public CCObject
class CC_DLL CCAnimation : public CCObject, public CCClonable
{
public:
CCAnimation();
@ -136,6 +139,9 @@ public:
*/
bool initWithAnimationFrames(CCArray* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops);
/** returns a clone fo the animation */
virtual CCAnimation *clone() const;
virtual CCObject* copyWithZone(CCZone* pZone);
/** total Delay units of the CCAnimation. */

View File

@ -120,6 +120,15 @@ CCSpriteFrame::~CCSpriteFrame(void)
CC_SAFE_RELEASE(_texture);
}
CCSpriteFrame* CCSpriteFrame::clone() const
{
// no copy constructor
CCSpriteFrame *copy = new CCSpriteFrame();
copy->initWithTextureFilename(_textureFilename.c_str(), _rectInPixels, _rotated, _offsetInPixels, _originalSizeInPixels);
copy->setTexture(_texture);
return copy;
}
CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
{
CC_UNUSED_PARAM(pZone);

View File

@ -52,7 +52,7 @@ class CCZone;
CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(texture, rect, offset);
sprite->setDisplayFrame(frame);
*/
class CC_DLL CCSpriteFrame : public CCObject
class CC_DLL CCSpriteFrame : public CCObject, public CCClonable
{
public:
// attributes
@ -93,6 +93,10 @@ public:
public:
~CCSpriteFrame(void);
/** returns a clone of the SpriteFrame */
virtual CCSpriteFrame *clone() const;
virtual CCObject* copyWithZone(CCZone *pZone);
/** Create a CCSpriteFrame with a texture filename, rect in points.

View File

@ -910,6 +910,21 @@ CCBSetSpriteFrame::~CCBSetSpriteFrame()
CC_SAFE_RELEASE_NULL(mSpriteFrame);
}
CCBSetSpriteFrame* CCBSetSpriteFrame::clone() const
{
// no copy constructor
auto a = new CCBSetSpriteFrame();
a->initWithSpriteFrame(mSpriteFrame);
a->autorelease();
return a;
}
CCBSetSpriteFrame* CCBSetSpriteFrame::reverse() const
{
// returns a copy of itself
return this->clone();
}
CCObject* CCBSetSpriteFrame::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
@ -964,6 +979,21 @@ bool CCBSoundEffect::initWithSoundFile(const std::string &filename, float pitch,
return true;
}
CCBSoundEffect* CCBSoundEffect::clone() const
{
// no copy constructor
auto a = new CCBSoundEffect();
a->initWithSoundFile(mSoundFile, mPitch, mPan, mGain);
a->autorelease();
return a;
}
CCBSoundEffect* CCBSoundEffect::reverse() const
{
// returns a copy of itself
return this->clone();
}
CCObject* CCBSoundEffect::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
@ -1025,6 +1055,21 @@ bool CCBRotateTo::initWithDuration(float fDuration, float fAngle)
}
}
CCBRotateTo* CCBRotateTo::clone() const
{
// no copy constructor
auto a = new CCBRotateTo();
a->initWithDuration(_duration, mDstAngle);
a->autorelease();
return a;
}
CCBRotateTo* CCBRotateTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateTo");
return nullptr;
}
CCObject* CCBRotateTo::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
@ -1108,6 +1153,21 @@ void CCBRotateXTo::startWithTarget(CCNode *pNode)
mDiffAngle = mDstAngle - mStartAngle;
}
CCBRotateXTo* CCBRotateXTo::clone() const
{
// no copy constructor
auto a = new CCBRotateXTo();
a->initWithDuration(_duration, mDstAngle);
a->autorelease();
return a;
}
CCBRotateXTo* CCBRotateXTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateXTo");
return nullptr;
}
CCObject* CCBRotateXTo::copyWithZone(CCZone *pZone)
{
CCZone *pNewZone = NULL;
@ -1172,6 +1232,21 @@ bool CCBRotateYTo::initWithDuration(float fDuration, float fAngle)
}
}
CCBRotateYTo* CCBRotateYTo::clone() const
{
// no copy constructor
auto a = new CCBRotateYTo();
a->initWithDuration(_duration, mDstAngle);
a->autorelease();
return a;
}
CCBRotateYTo* CCBRotateYTo::reverse() const
{
CCAssert(false, "reverse() is not supported in CCBRotateXTo");
return nullptr;
}
void CCBRotateYTo::startWithTarget(CCNode *pNode)
{
@ -1229,6 +1304,20 @@ CCBEaseInstant* CCBEaseInstant::create(CCActionInterval *pAction)
return pRet;
}
CCBEaseInstant* CCBEaseInstant::clone() const
{
// no copy constructor
auto a = new CCBEaseInstant();
a->initWithAction(_inner);
a->autorelease();
return a;
}
CCBEaseInstant* CCBEaseInstant::reverse() const
{
return CCBEaseInstant::create(_inner->reverse());
}
void CCBEaseInstant::update(float dt)
{
if (dt < 0)

View File

@ -16,7 +16,7 @@ CCLayer* restartEaseAction();
// SpriteEase
//
//------------------------------------------------------------------
#define CCCA(x) (x->copy()->autorelease())
void SpriteEase::onEnter()
{
EaseSpriteDemo::onEnter();
@ -24,17 +24,17 @@ void SpriteEase::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
CCActionInterval* move_ease_in = CCEaseIn::create(move->clone(), 2.5f);
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
CCActionInterval* move_ease_out = CCEaseOut::create(move->clone(), 2.5f);
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
CCAction *a2 = _grossini->runAction(CCRepeatForever::create(seq1));
@ -76,20 +76,20 @@ void SpriteEaseInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
// id move_back = move->reverse();
CCActionInterval* move_ease_inout1 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.65f);
CCActionInterval* move_ease_inout1 = CCEaseInOut::create(move->clone(), 0.65f);
CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();
CCActionInterval* move_ease_inout2 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.35f);
CCActionInterval* move_ease_inout2 = CCEaseInOut::create(move->clone(), 1.35f);
CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse();
CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.0f);
CCActionInterval* move_ease_inout3 = CCEaseInOut::create(move->clone(), 1.0f);
CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create( move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create( move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create( move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL);
_tamara->runAction(CCRepeatForever::create(seq1));
_kathia->runAction(CCRepeatForever::create(seq2));
@ -115,17 +115,17 @@ void SpriteEaseExponential::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseExponentialIn::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_in = CCEaseExponentialIn::create(move->clone());
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseExponentialOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out = CCEaseExponentialOut::create(move->clone());
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
_grossini->runAction( CCRepeatForever::create(seq1));
@ -151,13 +151,13 @@ void SpriteEaseExponentialInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseExponentialInOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease = CCEaseExponentialInOut::create(move->clone() );
CCActionInterval* move_ease_back = move_ease->reverse(); //--> reverse()
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create( move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create( move_ease, delay, move_ease_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create( move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create( move_ease, delay, move_ease_back, delay->clone(), NULL);
this->positionForTwo();
@ -184,17 +184,17 @@ void SpriteEaseSine::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseSineIn::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_in = CCEaseSineIn::create(move->clone() );
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseSineOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out = CCEaseSineOut::create(move->clone() );
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
_grossini->runAction( CCRepeatForever::create(seq1));
@ -221,13 +221,13 @@ void SpriteEaseSineInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseSineInOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease = CCEaseSineInOut::create(move->clone() );
CCActionInterval* move_ease_back = move_ease->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
this->positionForTwo();
@ -253,17 +253,17 @@ void SpriteEaseElastic::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseElasticIn::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_in = CCEaseElasticIn::create(move->clone() );
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseElasticOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out = CCEaseElasticOut::create(move->clone() );
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
_grossini->runAction( CCRepeatForever::create(seq1));
_tamara->runAction( CCRepeatForever::create(seq2));
@ -288,20 +288,20 @@ void SpriteEaseElasticInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.3f);
CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::create(move->clone(), 0.3f);
CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse();
CCActionInterval* move_ease_inout2 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.45f);
CCActionInterval* move_ease_inout2 = CCEaseElasticInOut::create(move->clone(), 0.45f);
CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse();
CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.6f);
CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::create(move->clone(), 0.6f);
CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL);
_tamara->runAction( CCRepeatForever::create(seq1));
_kathia->runAction( CCRepeatForever::create(seq2));
@ -328,17 +328,17 @@ void SpriteEaseBounce::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseBounceIn::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_in = CCEaseBounceIn::create(move->clone() );
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseBounceOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease_out = CCEaseBounceOut::create(move->clone() );
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
_grossini->runAction( CCRepeatForever::create(seq1));
_tamara->runAction( CCRepeatForever::create(seq2));
@ -365,13 +365,13 @@ void SpriteEaseBounceInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseBounceInOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease = CCEaseBounceInOut::create(move->clone() );
CCActionInterval* move_ease_back = move_ease->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
this->positionForTwo();
@ -398,17 +398,17 @@ void SpriteEaseBack::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease_in = CCEaseBackIn::create((CCActionInterval*)(move->copy()->autorelease()));
CCActionInterval* move_ease_in = CCEaseBackIn::create(move->clone());
CCActionInterval* move_ease_in_back = move_ease_in->reverse();
CCActionInterval* move_ease_out = CCEaseBackOut::create((CCActionInterval*)(move->copy()->autorelease()));
CCActionInterval* move_ease_out = CCEaseBackOut::create( move->clone());
CCActionInterval* move_ease_out_back = move_ease_out->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
CCSequence* seq3 = CCSequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
_grossini->runAction(CCRepeatForever::create(seq1));
_tamara->runAction(CCRepeatForever::create(seq2));
@ -434,13 +434,13 @@ void SpriteEaseBackInOut::onEnter()
CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
CCActionInterval* move_back = move->reverse();
CCActionInterval* move_ease = CCEaseBackInOut::create((CCActionInterval*)(move->copy()->autorelease()) );
CCActionInterval* move_ease = CCEaseBackInOut::create(move->clone() );
CCActionInterval* move_ease_back = move_ease->reverse();
CCDelayTime *delay = CCDelayTime::create(0.25f);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL);
CCSequence* seq1 = CCSequence::create(move, delay, move_back, delay->clone(), NULL);
CCSequence* seq2 = CCSequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
this->positionForTwo();
@ -478,8 +478,8 @@ void SpeedTest::onEnter()
CCSpeed* action = CCSpeed::create(CCRepeatForever::create(spawn), 1.0f);
action->setTag(kTagAction1);
CCAction* action2 = (CCAction*)(action->copy()->autorelease());
CCAction* action3 = (CCAction*)(action->copy()->autorelease());
CCAction* action2 = action->clone();
CCAction* action3 = action->clone();
action2->setTag(kTagAction1);
action3->setTag(kTagAction1);

View File

@ -258,7 +258,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
addChild(left);
left->setMidpoint(ccp(0.25f, 0.75f));
left->setPosition(ccp(100, s.height/2));
left->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));
left->runAction(CCRepeatForever::create(action->clone()));
/**
* Our image on the left should be a radial progress indicator, counter clockwise
@ -273,7 +273,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
*/
addChild(right);
right->setPosition(ccp(s.width-100, s.height/2));
right->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease()));
right->runAction(CCRepeatForever::create(action->clone()));
}
std::string SpriteProgressToRadialMidpointChanged::subtitle()
@ -303,7 +303,7 @@ void SpriteProgressBarVarious::onEnter()
left->setBarChangeRate(ccp(1, 0));
addChild(left);
left->setPosition(ccp(100, s.height/2));
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
left->runAction(CCRepeatForever::create(to->clone()));
CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
middle->setType(kCCProgressTimerTypeBar);
@ -313,7 +313,7 @@ void SpriteProgressBarVarious::onEnter()
middle->setBarChangeRate(ccp(1,1));
addChild(middle);
middle->setPosition(ccp(s.width/2, s.height/2));
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
middle->runAction(CCRepeatForever::create(to->clone()));
CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2));
right->setType(kCCProgressTimerTypeBar);
@ -323,7 +323,7 @@ void SpriteProgressBarVarious::onEnter()
right->setBarChangeRate(ccp(0, 1));
addChild(right);
right->setPosition(ccp(s.width-100, s.height/2));
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
right->runAction(CCRepeatForever::create(to->clone()));
}
std::string SpriteProgressBarVarious::subtitle()
@ -343,13 +343,13 @@ void SpriteProgressBarTintAndFade::onEnter()
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCProgressTo *to = CCProgressTo::create(6, 100);
CCAction *tint = CCSequence::create(CCTintTo::create(1, 255, 0, 0),
CCTintTo::create(1, 0, 255, 0),
CCTintTo::create(1, 0, 0, 255),
NULL);
CCAction *fade = CCSequence::create(CCFadeTo::create(1.0f, 0),
CCFadeTo::create(1.0f, 255),
NULL);
auto tint = CCSequence::create(CCTintTo::create(1, 255, 0, 0),
CCTintTo::create(1, 0, 255, 0),
CCTintTo::create(1, 0, 0, 255),
NULL);
auto fade = CCSequence::create(CCFadeTo::create(1.0f, 0),
CCFadeTo::create(1.0f, 255),
NULL);
CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1));
left->setType(kCCProgressTimerTypeBar);
@ -360,8 +360,8 @@ void SpriteProgressBarTintAndFade::onEnter()
left->setBarChangeRate(ccp(1, 0));
addChild(left);
left->setPosition(ccp(100, s.height/2));
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
left->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));
left->runAction(CCRepeatForever::create(to->clone()));
left->runAction(CCRepeatForever::create(tint->clone()));
left->addChild(CCLabelTTF::create("Tint", "Marker Felt", 20.0f));
@ -373,8 +373,8 @@ void SpriteProgressBarTintAndFade::onEnter()
middle->setBarChangeRate(ccp(1, 1));
addChild(middle);
middle->setPosition(ccp(s.width/2, s.height/2));
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
middle->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));
middle->runAction(CCRepeatForever::create(to->clone()));
middle->runAction(CCRepeatForever::create(fade->clone()));
middle->addChild(CCLabelTTF::create("Fade", "Marker Felt", 20.0f));
@ -386,9 +386,9 @@ void SpriteProgressBarTintAndFade::onEnter()
right->setBarChangeRate(ccp(0, 1));
addChild(right);
right->setPosition(ccp(s.width-100, s.height/2));
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
right->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease()));
right->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease()));
right->runAction(CCRepeatForever::create(to->clone()));
right->runAction(CCRepeatForever::create(tint->clone()));
right->runAction(CCRepeatForever::create(fade->clone()));
right->addChild(CCLabelTTF::create("Tint and Fade", "Marker Felt", 20.0f));
}
@ -421,7 +421,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
left->setBarChangeRate(ccp(1, 0));
addChild(left);
left->setPosition(ccp(100, s.height/2));
left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
left->runAction(CCRepeatForever::create(to->clone()));
CCProgressTimer *middle = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_02.png"));
middle->setType(kCCProgressTimerTypeBar);
@ -431,7 +431,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
middle->setBarChangeRate(ccp(1, 1));
addChild(middle);
middle->setPosition(ccp(s.width/2, s.height/2));
middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
middle->runAction(CCRepeatForever::create(to->clone()));
CCProgressTimer *right = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_03.png"));
right->setType(kCCProgressTimerTypeRadial);
@ -441,7 +441,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
right->setBarChangeRate(ccp(0, 1));
addChild(right);
right->setPosition(ccp(s.width-100, s.height/2));
right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease()));
right->runAction(CCRepeatForever::create(to->clone()));
}
std::string SpriteProgressWithSpriteFrame::subtitle()

View File

@ -3,6 +3,7 @@
#include "cocos2d.h"
static std::function<CCLayer*()> createFunctions[] = {
CL(ActionManual),
CL(ActionMove),
CL(ActionRotate),
@ -466,7 +467,7 @@ void ActionRotate::onEnter()
CCActionInterval* actionByBack = actionBy->reverse();
_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL));
_kathia->runAction( CCSequence::create(actionTo2, actionTo0->copy()->autorelease(), NULL));
_kathia->runAction( CCSequence::create(actionTo2, actionTo0->clone(), NULL));
}
std::string ActionRotate::subtitle()
@ -525,7 +526,7 @@ void ActionBezier::onEnter()
CCActionInterval* bezierForward = CCBezierBy::create(3, bezier);
CCActionInterval* bezierBack = bezierForward->reverse();
CCAction* rep = CCRepeatForever::create(CCSequence::create( bezierForward, bezierBack, NULL));
CCAction* rep = CCRepeatForever::create((CCActionInterval*)CCSequence::create( bezierForward, bezierBack, NULL));
// sprite 2
@ -679,7 +680,7 @@ void ActionAnimate::onEnter()
// File animation
//
// with 4 loops
CCAnimation *animation3 = (CCAnimation *)animation2->copy()->autorelease();
CCAnimation *animation3 = animation2->clone();
animation3->setLoops(4);
@ -1037,7 +1038,7 @@ void ActionRotateToRepeat::onEnter()
CCActionInterval* act2 = CCRotateTo::create(1, 0);
CCActionInterval* seq = CCSequence::create(act1, act2, NULL);
CCAction* rep1 = CCRepeatForever::create(seq);
CCActionInterval* rep2 = CCRepeat::create((CCFiniteTimeAction*)(seq->copy()->autorelease()), 10);
CCActionInterval* rep2 = CCRepeat::create( seq->clone(), 10);
_tamara->runAction(rep1);
_kathia->runAction(rep2);
@ -1066,7 +1067,7 @@ void ActionRotateJerk::onEnter()
NULL);
CCActionInterval* rep1 = CCRepeat::create(seq, 10);
CCAction* rep2 = CCRepeatForever::create( (CCActionInterval*)(seq->copy()->autorelease()) );
CCAction* rep2 = CCRepeatForever::create( (CCActionInterval*) seq->clone() );
_tamara->runAction(rep1);
_kathia->runAction(rep2);
@ -1162,26 +1163,23 @@ void ActionReverseSequence2::onEnter()
// Test:
// Sequence should work both with IntervalAction and InstantActions
CCActionInterval* move1 = CCMoveBy::create(1, ccp(250,0));
CCActionInterval* move2 = CCMoveBy::create(1, ccp(0,50));
CCToggleVisibility* tog1 = CCToggleVisibility::create();
CCToggleVisibility* tog2 = CCToggleVisibility::create();
tog1->autorelease();
tog2->autorelease();
CCFiniteTimeAction* seq = CCSequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL);
CCActionInterval* action = CCRepeat::create(CCSequence::create( seq, seq->reverse(), NULL), 3);
auto move1 = CCMoveBy::create(1, ccp(250,0));
auto move2 = CCMoveBy::create(1, ccp(0,50));
auto tog1 = CCToggleVisibility::create();
auto tog2 = CCToggleVisibility::create();
auto seq = CCSequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL);
auto action = CCRepeat::create(CCSequence::create( seq, seq->reverse(), NULL), 3);
// Test:
// Also test that the reverse of Hide is Show, and vice-versa
_kathia->runAction(action);
CCActionInterval* move_tamara = CCMoveBy::create(1, ccp(100,0));
CCActionInterval* move_tamara2 = CCMoveBy::create(1, ccp(50,0));
CCActionInstant* hide = CCHide::create();
CCFiniteTimeAction* seq_tamara = CCSequence::create( move_tamara, hide, move_tamara2, NULL);
CCFiniteTimeAction* seq_back = seq_tamara->reverse();
auto move_tamara = CCMoveBy::create(1, ccp(100,0));
auto move_tamara2 = CCMoveBy::create(1, ccp(50,0));
auto hide = CCHide::create();
auto seq_tamara = CCSequence::create( move_tamara, hide, move_tamara2, NULL);
auto seq_back = seq_tamara->reverse();
_tamara->runAction( CCSequence::create( seq_tamara, seq_back, NULL));
}
std::string ActionReverseSequence2::subtitle()
@ -1206,7 +1204,7 @@ void ActionRepeat::onEnter()
CCSequence::create( CCPlace::create(ccp(60,60)), a1, NULL) ,
3);
CCAction* action2 = CCRepeatForever::create(
CCSequence::create((CCActionInterval*)(a1->copy()->autorelease()), a1->reverse(), NULL)
CCSequence::create((CCActionInterval*)(a1->clone()), a1->reverse(), NULL)
);
_kathia->runAction(action1);
@ -1256,8 +1254,8 @@ void ActionOrbit::onEnter()
CCSequence* seq = CCSequence::create(move, move_back, NULL);
CCAction* rfe = CCRepeatForever::create(seq);
_kathia->runAction(rfe);
_tamara->runAction((CCAction*)(rfe->copy()->autorelease()));
_grossini->runAction((CCAction*)(rfe->copy()->autorelease()));
_tamara->runAction(rfe->clone() );
_grossini->runAction( rfe->clone() );
}
std::string ActionOrbit::subtitle()
@ -1311,9 +1309,9 @@ void ActionTargeted::onEnter()
CCJumpBy* jump1 = CCJumpBy::create(2,CCPointZero,100,3);
CCJumpBy* jump2 = (CCJumpBy*)jump1->copy()->autorelease();
CCJumpBy* jump2 = jump1->clone();
CCRotateBy* rot1 = CCRotateBy::create(1, 360);
CCRotateBy* rot2 = (CCRotateBy*)rot1->copy()->autorelease();
CCRotateBy* rot2 = rot1->clone();
CCTargetedAction *t1 = CCTargetedAction::create(_kathia, jump2);
CCTargetedAction *t2 = CCTargetedAction::create(_kathia, rot2);
@ -1410,7 +1408,7 @@ void ActionMoveStacked::runActionsInSprite(CCSprite *sprite)
NULL)));
CCMoveBy* action = CCMoveBy::create(2.0f, ccp(400,0));
CCMoveBy* action_back = (CCMoveBy*)action->reverse();
CCMoveBy* action_back = action->reverse();
sprite->runAction(
CCRepeatForever::create(
@ -1436,7 +1434,7 @@ void ActionMoveJumpStacked::runActionsInSprite(CCSprite *sprite)
NULL)));
CCJumpBy* jump = CCJumpBy::create(2.0f, ccp(400,0), 100, 5);
CCJumpBy* jump_back = (CCJumpBy*)jump->reverse();
CCJumpBy* jump_back = jump->reverse();
sprite->runAction(
CCRepeatForever::create(
@ -1462,7 +1460,7 @@ void ActionMoveBezierStacked::runActionsInSprite(CCSprite *sprite)
bezier.endPosition = ccp(300,100);
CCBezierBy* bezierForward = CCBezierBy::create(3, bezier);
CCBezierBy* bezierBack = (CCBezierBy*)bezierForward->reverse();
CCBezierBy* bezierBack = bezierForward->reverse();
CCSequence* seq = CCSequence::create(bezierForward, bezierBack, NULL);
CCRepeatForever* rep = CCRepeatForever::create(seq);
sprite->runAction(rep);
@ -1511,7 +1509,7 @@ void ActionCatmullRomStacked::onEnter()
array->addControlPoint(ccp(s.width/2, s.height/2));
CCCatmullRomBy *action = CCCatmullRomBy::create(3, array);
CCCatmullRomBy* reverse = (CCCatmullRomBy*)action->reverse();
CCCatmullRomBy* reverse = action->reverse();
CCSequence *seq = CCSequence::create(action, reverse, NULL);
@ -1543,7 +1541,7 @@ void ActionCatmullRomStacked::onEnter()
CCCatmullRomTo *action2 = CCCatmullRomTo::create(3, array2);
CCCatmullRomTo* reverse2 = (CCCatmullRomTo*)action2->reverse();
CCCatmullRomTo* reverse2 = action2->reverse();
CCSequence *seq2 = CCSequence::create(action2, reverse2, NULL);
@ -1621,7 +1619,7 @@ void ActionCardinalSplineStacked::onEnter()
CCCatmullRomBy *action = (CCCatmullRomBy*)CCCardinalSplineBy::create(3, array, 0);
CCCatmullRomBy* reverse = (CCCatmullRomBy*)action->reverse();
CCCatmullRomBy* reverse = action->reverse();
CCSequence *seq = CCSequence::create(action, reverse, NULL);
@ -1642,8 +1640,8 @@ void ActionCardinalSplineStacked::onEnter()
// Spline with high tension (tension==1)
//
CCCatmullRomBy *action2 = (CCCatmullRomBy*)CCCardinalSplineBy::create(3, array, 1);
CCCatmullRomBy* reverse2 = (CCCatmullRomBy*)action2->reverse();
CCCardinalSplineBy *action2 = CCCardinalSplineBy::create(3, array, 1);
CCCardinalSplineBy* reverse2 = action2->reverse();
CCSequence *seq2 = CCSequence::create(action2, reverse2, NULL);
@ -1826,7 +1824,7 @@ void Issue1288::onEnter()
addChild(spr);
CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0));
CCMoveBy* act2 = (CCMoveBy*)act1->reverse();
CCMoveBy* act2 = act1->reverse();
CCFiniteTimeAction* act3 = CCSequence::create(act1, act2, NULL);
CCRepeat* act4 = CCRepeat::create(act3, 2);

View File

@ -79,7 +79,7 @@ void Effect2::onEnter()
// id orbit_back = [orbit reverse];
//
// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]];
target->runAction(CCSequence::create( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) );
target->runAction(CCSequence::create( shaky, delay, reuse, shuffle, delay->clone(), turnoff, turnon, NULL) );
}
std::string Effect2::title()

View File

@ -141,9 +141,9 @@ void ArmatureTestLayer::onEnter()
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ArmatureTestLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ArmatureTestLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ArmatureTestLayer::nextCallback) );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(ArmatureTestLayer::backCallback,this));
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(ArmatureTestLayer::restartCallback, this));
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(ArmatureTestLayer::nextCallback, this));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);

View File

@ -80,7 +80,7 @@ cocos2d::CCNode* ComponentsTestLayer::createGameScene()
root->addChild(player, 1, 1);
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(ComponentsTestLayer::toExtensionsMainLayer));
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", CC_CALLBACK_1(ComponentsTestLayer::toExtensionsMainLayer,this));
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);