fixed #533: upgrade actions to 1.0.0-r3

This commit is contained in:
minggo 2011-07-01 15:08:23 +08:00
parent 25b3b15151
commit 7bdf2cb84e
12 changed files with 409 additions and 99 deletions

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -119,7 +120,7 @@ CCFiniteTimeAction *CCFiniteTimeAction::reverse()
//
CCSpeed::~CCSpeed()
{
CC_SAFE_RELEASE(m_pOther);
CC_SAFE_RELEASE(m_pInnerAction);
}
CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fRate)
@ -138,7 +139,7 @@ bool CCSpeed::initWithAction(CCActionInterval *pAction, float fRate)
{
assert(pAction != NULL);
pAction->retain();
m_pOther = pAction;
m_pInnerAction = pAction;
m_fSpeed = fRate;
return true;
}
@ -158,7 +159,7 @@ CCObject *CCSpeed::copyWithZone(CCZone *pZone)
}
CCAction::copyWithZone(pZone);
pRet->initWithAction( (CCActionInterval*)(m_pOther->copy()->autorelease()) , m_fSpeed );
pRet->initWithAction( (CCActionInterval*)(m_pInnerAction->copy()->autorelease()) , m_fSpeed );
CC_SAFE_DELETE(pNewZone);
return pRet;
@ -167,28 +168,38 @@ CCObject *CCSpeed::copyWithZone(CCZone *pZone)
void CCSpeed::startWithTarget(CCNode* pTarget)
{
CCAction::startWithTarget(pTarget);
m_pOther->startWithTarget(pTarget);
m_pInnerAction->startWithTarget(pTarget);
}
void CCSpeed::stop()
{
m_pOther->stop();
m_pInnerAction->stop();
CCAction::stop();
}
void CCSpeed::step(ccTime dt)
{
m_pOther->step(dt * m_fSpeed);
m_pInnerAction->step(dt * m_fSpeed);
}
bool CCSpeed::isDone()
{
return m_pOther->isDone();
return m_pInnerAction->isDone();
}
CCActionInterval *CCSpeed::reverse()
{
return (CCActionInterval*)(CCSpeed::actionWithAction(m_pOther->reverse(), m_fSpeed));
return (CCActionInterval*)(CCSpeed::actionWithAction(m_pInnerAction->reverse(), m_fSpeed));
}
void CCSpeed::setInnerAction(CCActionInterval *pAction)
{
if (m_pInnerAction != pAction)
{
CC_SAFE_RELEASE(m_pInnerAction);
m_pInnerAction = pAction;
CC_SAFE_RETAIN(m_pInnerAction);
}
}
//

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -532,7 +533,7 @@ namespace cocos2d {
if( CCCallFunc::initWithTarget(pSelectorTarget) )
{
m_pObject = pObject;
m_pObject->retain();
CC_SAFE_RETAIN(m_pObject)
m_pCallFuncO = selector;
return true;

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -320,7 +321,7 @@ bool CCRepeat::initWithAction(cocos2d::CCFiniteTimeAction *pAction, unsigned int
if (CCActionInterval::initWithDuration(d))
{
m_uTimes = times;
m_pOther = pAction;
m_pInnerAction = pAction;
pAction->retain();
m_uTotal = 0;
@ -349,7 +350,7 @@ CCObject* CCRepeat::copyWithZone(cocos2d::CCZone *pZone)
CCActionInterval::copyWithZone(pZone);
pCopy->initWithAction((CCFiniteTimeAction*)(m_pOther->copy()->autorelease()), m_uTimes);
pCopy->initWithAction((CCFiniteTimeAction*)(m_pInnerAction->copy()->autorelease()), m_uTimes);
CC_SAFE_DELETE(pNewZone);
return pCopy;
@ -357,19 +358,19 @@ CCObject* CCRepeat::copyWithZone(cocos2d::CCZone *pZone)
CCRepeat::~CCRepeat(void)
{
CC_SAFE_RELEASE(m_pOther);
CC_SAFE_RELEASE(m_pInnerAction);
}
void CCRepeat::startWithTarget(CCNode *pTarget)
{
m_uTotal = 0;
CCActionInterval::startWithTarget(pTarget);
m_pOther->startWithTarget(pTarget);
m_pInnerAction->startWithTarget(pTarget);
}
void CCRepeat::stop(void)
{
m_pOther->stop();
m_pInnerAction->stop();
CCActionInterval::stop();
}
@ -380,22 +381,22 @@ void CCRepeat::update(cocos2d::ccTime time)
ccTime t = time * m_uTimes;
if (t > m_uTotal + 1)
{
m_pOther->update(1.0f);
m_pInnerAction->update(1.0f);
m_uTotal++;
m_pOther->stop();
m_pOther->startWithTarget(m_pTarget);
m_pInnerAction->stop();
m_pInnerAction->startWithTarget(m_pTarget);
// repeat is over?
if (m_uTotal == m_uTimes)
{
// so, set it in the original position
m_pOther->update(0);
m_pInnerAction->update(0);
}
else
{
// no ? start next repeat with the right update
// to prevent jerk (issue #390)
m_pOther->update(t - m_uTotal);
m_pInnerAction->update(t - m_uTotal);
}
}
else
@ -411,7 +412,7 @@ void CCRepeat::update(cocos2d::ccTime time)
}
// m_pOther->update(min(r, 1));
m_pOther->update(r > 1 ? 1 : r);
m_pInnerAction->update(r > 1 ? 1 : r);
}
}
@ -422,7 +423,7 @@ bool CCRepeat::isDone(void)
CCActionInterval* CCRepeat::reverse(void)
{
return CCRepeat::actionWithAction(m_pOther->reverse(), m_uTimes);
return CCRepeat::actionWithAction(m_pInnerAction->reverse(), m_uTimes);
}
//
@ -430,7 +431,7 @@ CCActionInterval* CCRepeat::reverse(void)
//
CCRepeatForever::~CCRepeatForever()
{
CC_SAFE_RELEASE(m_pOther);
CC_SAFE_RELEASE(m_pInnerAction);
}
CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction)
{
@ -448,7 +449,7 @@ bool CCRepeatForever::initWithAction(CCActionInterval *pAction)
{
assert(pAction != NULL);
pAction->retain();
m_pOther = pAction;
m_pInnerAction = pAction;
return true;
}
CCObject* CCRepeatForever::copyWithZone(CCZone *pZone)
@ -466,7 +467,7 @@ CCObject* CCRepeatForever::copyWithZone(CCZone *pZone)
}
CCActionInterval::copyWithZone(pZone);
// win32 : use the m_pOther's copy object.
pRet->initWithAction((CCActionInterval*)(m_pOther->copy()->autorelease()));
pRet->initWithAction((CCActionInterval*)(m_pInnerAction->copy()->autorelease()));
CC_SAFE_DELETE(pNewZone);
return pRet;
}
@ -474,18 +475,18 @@ CCObject* CCRepeatForever::copyWithZone(CCZone *pZone)
void CCRepeatForever::startWithTarget(CCNode* pTarget)
{
CCActionInterval::startWithTarget(pTarget);
m_pOther->startWithTarget(pTarget);
m_pInnerAction->startWithTarget(pTarget);
}
void CCRepeatForever::step(ccTime dt)
{
m_pOther->step(dt);
if (m_pOther->isDone())
m_pInnerAction->step(dt);
if (m_pInnerAction->isDone())
{
ccTime diff = dt + m_pOther->getDuration() - m_pOther->getElapsed();
m_pOther->startWithTarget(m_pTarget);
ccTime diff = dt + m_pInnerAction->getDuration() - m_pInnerAction->getElapsed();
m_pInnerAction->startWithTarget(m_pTarget);
// to prevent jerk. issue #390
m_pOther->step(diff);
m_pInnerAction->step(diff);
}
}
@ -496,7 +497,7 @@ bool CCRepeatForever::isDone()
CCActionInterval *CCRepeatForever::reverse()
{
return (CCActionInterval*)(CCRepeatForever::actionWithAction(m_pOther->reverse()));
return (CCActionInterval*)(CCRepeatForever::actionWithAction(m_pInnerAction->reverse()));
}
//
@ -895,10 +896,186 @@ CCActionInterval* CCMoveBy::reverse(void)
return CCMoveBy::actionWithDuration(m_fDuration, ccp(-m_delta.x, -m_delta.y));
}
//
// CCSkewTo
//
CCSkewTo* CCSkewTo::actionWithDuration(cocos2d::ccTime t, float sx, float sy)
{
CCSkewTo *pSkewTo = new CCSkewTo();
if (pSkewTo)
{
if (pSkewTo->initWithDuration(t, sx, sy))
{
pSkewTo->autorelease();
}
else
{
CC_SAFE_DELETE(pSkewTo);
}
}
return pSkewTo;
}
bool CCSkewTo::initWithDuration(ccTime t, float sx, float sy)
{
bool bRet = false;
if (CCActionInterval::initWithDuration(t))
{
m_fEndSkewX = sx;
m_fEndSkewY = sy;
bRet = true;
}
return bRet;
}
CCObject* CCSkewTo::copyWithZone(CCZone* pZone)
{
CCZone* pNewZone = NULL;
CCSkewTo* pCopy = NULL;
if(pZone && pZone->m_pCopyObject)
{
//in case of being called at sub class
pCopy = (CCSkewTo*)(pZone->m_pCopyObject);
}
else
{
pCopy = new CCSkewTo();
pZone = pNewZone = new CCZone(pCopy);
}
CCActionInterval::copyWithZone(pZone);
pCopy->initWithDuration(m_fDuration, m_fEndSkewX, m_fEndSkewY);
CC_SAFE_DELETE(pNewZone);
return pCopy;
}
void CCSkewTo::startWithTarget(cocos2d::CCNode *pTarget)
{
CCActionInterval::startWithTarget(pTarget);
m_fStartSkewX = pTarget->getSkewX();
if (m_fStartSkewX > 0)
{
m_fStartSkewX = fmodf(m_fStartSkewX, 180.f);
}
else
{
m_fStartSkewX = fmodf(m_fStartSkewX, -180.f);
}
m_fDeltaX = m_fEndSkewX - m_fStartSkewX;
if (m_fDeltaX > 180)
{
m_fDeltaX -= 360;
}
if (m_fDeltaX < -180)
{
m_fDeltaX += 360;
}
m_fSkewY = pTarget->getSkewY();
if (m_fStartSkewY > 0)
{
m_fStartSkewY = fmodf(m_fStartSkewY, 360.f);
}
else
{
m_fStartSkewY = fmodf(m_fStartSkewY, -360.f);
}
m_fDeltaY = m_fEndSkewY - m_fStartSkewY;
if (m_fDeltaY > 180)
{
m_fDeltaY -= 360;
}
if (m_fDeltaY < -180)
{
m_fDeltaY += 360;
}
}
void CCSkewTo::update(ccTime t)
{
m_pTarget->setSkewX(m_fStartSkewX + m_fDeltaX * t);
m_pTarget->setSkewY(m_fStartSkewY + m_fDeltaY * t);
}
CCSkewTo::CCSkewTo()
: m_fSkewX(0.0)
, m_fSkewY(0.0)
, m_fStartSkewX(0.0)
, m_fStartSkewY(0.0)
, m_fEndSkewX(0.0)
, m_fEndSkewY(0.0)
, m_fDeltaX(0.0)
, m_fDeltaY(0.0)
{
}
//
// CCSkewBy
//
CCSkewBy* CCSkewBy::actionWithDuration(ccTime t, float sx, float sy)
{
CCSkewBy *pSkewBy = new CCSkewBy();
if (pSkewBy)
{
if (pSkewBy->initWithDuration(t, sx, sy))
{
pSkewBy->autorelease();
}
else
{
CC_SAFE_DELETE(pSkewBy);
}
}
return pSkewBy;
}
bool CCSkewBy::initWithDuration(cocos2d::ccTime t, float deltaSkewX, float deltaSkewY)
{
bool bRet = false;
if (CCSkewTo::initWithDuration(t, deltaSkewX, deltaSkewY))
{
m_fSkewX = deltaSkewX;
m_fSkewY = deltaSkewY;
bRet = true;
}
return bRet;
}
void CCSkewBy::startWithTarget(cocos2d::CCNode *pTarget)
{
CCSkewTo::startWithTarget(pTarget);
m_fDeltaX = m_fSkewX;
m_fDeltaY = m_fSkewY;
m_fEndSkewX = m_fStartSkewX + m_fDeltaX;
m_fEndSkewY = m_fStartSkewY + m_fDeltaY;
}
CCActionInterval* CCSkewBy::reverse()
{
return actionWithDuration(m_fDuration, -m_fSkewX, -m_fSkewY);
}
//
// JumpBy
//
CCJumpBy* CCJumpBy::actionWithDuration(cocos2d::ccTime duration, cocos2d::CCPoint position, cocos2d::ccTime height, int jumps)
CCJumpBy* CCJumpBy::actionWithDuration(cocos2d::ccTime duration, cocos2d::CCPoint position, cocos2d::ccTime height, unsigned int jumps)
{
CCJumpBy *pJumpBy = new CCJumpBy();
pJumpBy->initWithDuration(duration, position, height, jumps);
@ -907,7 +1084,7 @@ CCJumpBy* CCJumpBy::actionWithDuration(cocos2d::ccTime duration, cocos2d::CCPoin
return pJumpBy;
}
bool CCJumpBy::initWithDuration(cocos2d::ccTime duration, cocos2d::CCPoint position, cocos2d::ccTime height, int jumps)
bool CCJumpBy::initWithDuration(cocos2d::ccTime duration, cocos2d::CCPoint position, cocos2d::ccTime height, unsigned int jumps)
{
if (CCActionInterval::initWithDuration(duration))
{
@ -1735,8 +1912,14 @@ CCReverseTime* CCReverseTime::actionWithAction(cocos2d::CCFiniteTimeAction *pAct
bool CCReverseTime::initWithAction(cocos2d::CCFiniteTimeAction *pAction)
{
assert(pAction != NULL);
assert(pAction != m_pOther);
if (CCActionInterval::initWithDuration(pAction->getDuration()))
{
// Don't leak if action is reused
CC_SAFE_RELEASE(m_pOther);
m_pOther = pAction;
pAction->retain();

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2009 Valentin Milea
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -166,12 +167,6 @@ void CCActionManager::removeActionAtIndex(unsigned int uIndex, tHashElement *pEl
// pause / resume
// XXX DEPRECATED. REMOVE IN 1.0
void CCActionManager::pauseAllActionsForTarget(CCObject *pTarget)
{
pauseTarget(pTarget);
}
void CCActionManager::pauseTarget(CCObject *pTarget)
{
tHashElement *pElement = NULL;
@ -182,12 +177,6 @@ void CCActionManager::pauseTarget(CCObject *pTarget)
}
}
// XXX DEPRECATED. REMOVE IN 1.0
void CCActionManager::resumeAllActionsForTarget(CCObject *pTarget)
{
resumeTarget(pTarget);
}
void CCActionManager::resumeTarget(CCObject *pTarget)
{
tHashElement *pElement = NULL;
@ -297,7 +286,7 @@ void CCActionManager::removeAction(cocos2d::CCAction *pAction)
}
}
void CCActionManager::removeActionByTag(int tag, CCObject *pTarget)
void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget)
{
assert(tag != kCCActionTagInvalid);
assert(pTarget != NULL);
@ -327,7 +316,7 @@ void CCActionManager::removeActionByTag(int tag, CCObject *pTarget)
// get
CCAction* CCActionManager::getActionByTag(int tag, CCObject *pTarget)
CCAction* CCActionManager::getActionByTag(unsigned int tag, CCObject *pTarget)
{
assert(tag != kCCActionTagInvalid);
@ -359,7 +348,7 @@ CCAction* CCActionManager::getActionByTag(int tag, CCObject *pTarget)
return NULL;
}
int CCActionManager::numberOfRunningActionsInTarget(CCObject *pTarget)
unsigned int CCActionManager::numberOfRunningActionsInTarget(CCObject *pTarget)
{
tHashElement *pElement = NULL;
HASH_FIND_INT(m_pTargets, &pTarget, pElement);

View File

@ -294,12 +294,12 @@ namespace cocos2d
CC_SAFE_DELETE_ARRAY(m_pTiles);
}
void CCShuffleTiles::shuffle(int *pArray, int nLen)
void CCShuffleTiles::shuffle(int *pArray, unsigned int nLen)
{
int i;
unsigned int i;
for( i = nLen - 1; i >= 0; i-- )
{
int j = rand() % (i+1);
unsigned int j = rand() % (i+1);
int v = pArray[i];
pArray[i] = pArray[j];
pArray[j] = v;
@ -310,7 +310,7 @@ namespace cocos2d
{
CCPoint pos2;
int idx = pos.x * m_sGridSize.y + pos.y;
unsigned int idx = pos.x * m_sGridSize.y + pos.y;
pos2.x = (float)(m_pTilesOrder[idx] / (int)m_sGridSize.y);
pos2.y = (float)(m_pTilesOrder[idx] % (int)m_sGridSize.y);
@ -350,10 +350,15 @@ namespace cocos2d
m_nTilesCount = m_sGridSize.x * m_sGridSize.y;
m_pTilesOrder = new int[m_nTilesCount];
int i, j;
unsigned int k;
for (i = 0; i < m_nTilesCount; ++i)
/**
* Use k to loop. Because m_nTilesCount is unsigned int,
* and i is used later for int.
*/
for (k = 0; k < m_nTilesCount; ++k)
{
m_pTilesOrder[i] = i;
m_pTilesOrder[k] = k;
}
shuffle(m_pTilesOrder, m_nTilesCount);
@ -660,12 +665,12 @@ namespace cocos2d
CC_SAFE_DELETE_ARRAY(m_pTilesOrder);
}
void CCTurnOffTiles::shuffle(int *pArray, int nLen)
void CCTurnOffTiles::shuffle(int *pArray, unsigned int nLen)
{
int i;
unsigned int i;
for (i = nLen - 1; i >= 0; i--)
{
int j = rand() % (i+1);
unsigned int j = rand() % (i+1);
int v = pArray[i];
pArray[i] = pArray[j];
pArray[j] = v;
@ -687,7 +692,7 @@ namespace cocos2d
void CCTurnOffTiles::startWithTarget(CCNode *pTarget)
{
int i;
unsigned int i;
CCTiledGrid3DAction::startWithTarget(pTarget);
@ -699,7 +704,7 @@ namespace cocos2d
m_nTilesCount = m_sGridSize.x * m_sGridSize.y;
m_pTilesOrder = new int[m_nTilesCount];
for ( i = 0; i < m_nTilesCount; ++i)
for (i = 0; i < m_nTilesCount; ++i)
{
m_pTilesOrder[i] = i;
}
@ -709,7 +714,7 @@ namespace cocos2d
void CCTurnOffTiles::update(cocos2d::ccTime time)
{
int i, l, t;
unsigned int i, l, t;
l = (int)(time * (float)m_nTilesCount);

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -82,7 +83,7 @@ public:
inline CCNode* getOriginalTarget(void) { return m_pOriginalTarget; }
/** Set the original target, since target can be nil.
Is the target that were used to run the action. Unless you are doing something complex, like ActionManager, you should NOT call this method.
Is the target that were used to run the action. Unless you are doing something complex, like CCActionManager, you should NOT call this method.
The target is 'assigned', it is not 'retained'.
@since v0.8.2
*/
@ -142,14 +143,14 @@ class CCRepeatForever;
@brief Changes the speed of an action, making it take longer (speed>1)
or less (speed<1) time.
Useful to simulate 'slow motion' or 'fast forward' effect.
@warning This action can't be Sequenceable because it is not an IntervalAction
@warning This action can't be Sequenceable because it is not an CCIntervalAction
*/
class CC_DLL CCSpeed : public CCAction
{
public:
CCSpeed()
: m_fSpeed(0.0)
, m_pOther(NULL)
, m_pInnerAction(NULL)
{}
virtual ~CCSpeed(void);
@ -167,13 +168,20 @@ public:
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
inline void setInnerAction(CCActionInterval *pAction);
inline CCActionInterval* getInnerAction()
{
return m_pInnerAction;
}
public:
/** creates the action */
static CCSpeed* actionWithAction(CCActionInterval *pAction, float fRate);
protected:
float m_fSpeed;
CCActionInterval *m_pOther;
CCActionInterval *m_pInnerAction;
};

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -204,9 +205,33 @@ namespace cocos2d {
void registerScriptFunction(const char* pszFunctionName);
inline SelectorProtocol* getTargetCallback()
{
return m_pSelectorTarget;
}
inline void setTargetCallback(SelectorProtocol* pSel)
{
if (pSel != m_pSelectorTarget)
{
if (m_pSelectorTarget)
{
m_pSelectorTarget->selectorProtocolRelease();
}
m_pSelectorTarget = pSel;
if (m_pSelectorTarget)
{
m_pSelectorTarget->selectorProtocolRetain();
}
}
}
protected:
/** Target that will be called */
SelectorProtocol* m_pSelectorTarget;
// the script function name to call back
/** the script function name to call back */
std::string m_scriptFuncName;
union
@ -291,7 +316,23 @@ namespace cocos2d {
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void execute();
inline CCObject* getObject()
{
return m_pObject;
}
inline void setObject(CCObject* pObj)
{
if (pObj != m_pObject)
{
CC_SAFE_RELEASE(m_pObject);
m_pObject = pObj;
CC_SAFE_RETAIN(m_pObject);
}
}
protected:
/** object to be passed as argument */
CCObject* m_pObject;
};

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2008-2011 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -102,6 +103,8 @@ public:
public:
/** helper constructor to create an array of sequenceable actions */
static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of sequenceable actions given an array */
static CCFiniteTimeAction* actionsWithArray(CCArray *actions);
/** creates the action */
static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
@ -129,6 +132,21 @@ public:
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
inline void setInnerAction(CCFiniteTimeAction *pAction)
{
if (m_pInnerAction != pAction)
{
CC_SAFE_RELEASE(m_pInnerAction);
m_pInnerAction = pAction;
CC_SAFE_RETAIN(m_pInnerAction);
}
}
inline CCFiniteTimeAction* getInnerAction()
{
return m_pInnerAction;
}
public:
/** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times);
@ -136,7 +154,8 @@ public:
protected:
unsigned int m_uTimes;
unsigned int m_uTotal;
CCFiniteTimeAction *m_pOther;
/** Inner action */
CCFiniteTimeAction *m_pInnerAction;
};
/** @brief Repeats an action for ever.
@ -147,7 +166,7 @@ class CC_DLL CCRepeatForever : public CCActionInterval
{
public:
CCRepeatForever()
: m_pOther(NULL)
: m_pInnerAction(NULL)
{}
virtual ~CCRepeatForever();
@ -159,12 +178,28 @@ public:
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
inline void setInnerAction(CCActionInterval *pAction)
{
if (m_pInnerAction != pAction)
{
CC_SAFE_RELEASE(m_pInnerAction);
m_pInnerAction = pAction;
CC_SAFE_RETAIN(m_pInnerAction);
}
}
inline CCActionInterval* getInnerAction()
{
return m_pInnerAction;
}
public:
/** creates the action */
static CCRepeatForever* actionWithAction(CCActionInterval *pAction);
protected:
CCActionInterval *m_pOther;
/** Inner action */
CCActionInterval *m_pInnerAction;
};
/** @brief Spawn a new action immediately
@ -187,6 +222,9 @@ public:
/** helper constructor to create an array of spawned actions */
static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of spawned actions given an array */
static CCFiniteTimeAction* actionsWithArray(CCArray *actions);
/** creates the Spawn action */
static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
@ -282,13 +320,53 @@ public:
static CCMoveBy* actionWithDuration(ccTime duration, CCPoint position);
};
/** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes
@since v1.0
*/
class CC_DLL CCSkewTo : public CCActionInterval
{
public:
CCSkewTo();
virtual bool initWithDuration(ccTime t, float sx, float sy);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(ccTime time);
public:
static CCSkewTo* actionWithDuration(ccTime t, float sx, float sy);
protected:
float m_fSkewX;
float m_fSkewY;
float m_fStartSkewX;
float m_fStartSkewY;
float m_fEndSkewX;
float m_fEndSkewY;
float m_fDeltaX;
float m_fDeltaY;
};
/** Skews a CCNode object by skewX and skewY degrees
@since v1.0
*/
class CC_DLL CCSkewBy : public CCSkewTo
{
public:
virtual bool initWithDuration(ccTime t, float sx, float sy);
virtual void startWithTarget(CCNode *pTarget);
virtual CCActionInterval* reverse(void);
public:
static CCSkewBy* actionWithDuration(ccTime t, float deltaSkewX, float deltaSkewY);
};
/** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
*/
class CC_DLL CCJumpBy : public CCActionInterval
{
public:
/** initializes the action */
bool initWithDuration(ccTime duration, CCPoint position, ccTime height, int jumps);
bool initWithDuration(ccTime duration, CCPoint position, ccTime height, unsigned int jumps);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
@ -297,13 +375,13 @@ public:
public:
/** creates the action */
static CCJumpBy* actionWithDuration(ccTime duration, CCPoint position, ccTime height, int jumps);
static CCJumpBy* actionWithDuration(ccTime duration, CCPoint position, ccTime height, unsigned int jumps);
protected:
CCPoint m_startPosition;
CCPoint m_delta;
ccTime m_height;
int m_nJumps;
unsigned int m_nJumps;
};
/** @brief Moves a CCNode object to a parabolic position simulating a jump movement by modifying it's position attribute.
@ -432,7 +510,7 @@ public:
/** creates the action */
static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks);
protected:
int m_nTimes;
unsigned int m_nTimes;
};
/** @brief Fades In an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 0 to 255.

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2009 Valentin Milea
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -76,19 +77,19 @@ public:
void removeAction(CCAction *pAction);
/** Removes an action given its tag and the target */
void removeActionByTag(int tag, CCObject *pTarget);
void removeActionByTag(unsigned int tag, CCObject *pTarget);
/** Gets an action given its tag an a target
@return the Action the with the given tag
*/
CCAction* getActionByTag(int tag, CCObject *pTarget);
CCAction* getActionByTag(unsigned int tag, CCObject *pTarget);
/** Returns the numbers of actions that are running in a certain target.
* Composable actions are counted as 1 action. Example:
* - If you are running 1 Sequence of 7 actions, it will return 1.
* - If you are running 7 Sequences of 2 actions, it will return 7.
*/
int numberOfRunningActionsInTarget(CCObject *pTarget);
unsigned int numberOfRunningActionsInTarget(CCObject *pTarget);
/** Pauses the target: all running actions and newly added actions will be paused.
*/
@ -98,15 +99,6 @@ public:
*/
void resumeTarget(CCObject *pTarget);
/** Resumes the target. All queued actions will be resumed.
@deprecated Use resumeTarget: instead. Will be removed in v1.0.
*/
void resumeAllActionsForTarget(CCObject *pTarget);
/** Pauses the target: all running actions and newly added actions will be paused.
*/
void pauseAllActionsForTarget(CCObject *pTarget);
/** purges the shared action manager. It releases the retained instance.
* because it uses this, so it can not be static
@since v0.99.0

View File

@ -82,7 +82,7 @@ namespace cocos2d
~CCShuffleTiles(void);
/** initializes the action with a random seed, the grid size and the duration */
bool initWithSeed(int s, ccGridSize gridSize, ccTime duration);
void shuffle(int *pArray, int nLen);
void shuffle(int *pArray, unsigned int nLen);
ccGridSize getDelta(ccGridSize pos);
void placeTile(ccGridSize pos, Tile *t);
@ -96,7 +96,7 @@ namespace cocos2d
protected:
int m_nSeed;
int m_nTilesCount;
unsigned int m_nTilesCount;
int *m_pTilesOrder;
Tile *m_pTiles;
};
@ -167,7 +167,7 @@ namespace cocos2d
~CCTurnOffTiles(void);
/** initializes the action with a random seed, the grid size and the duration */
bool initWithSeed(int s, ccGridSize gridSize, ccTime duration);
void shuffle(int *pArray, int nLen);
void shuffle(int *pArray, unsigned int nLen);
void turnOnTile(ccGridSize pos);
void turnOffTile(ccGridSize pos);
@ -183,7 +183,7 @@ namespace cocos2d
protected:
int m_nSeed;
int m_nTilesCount;
unsigned int m_nTilesCount;
int *m_pTilesOrder;
};

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org