mirror of https://github.com/axmolengine/axmol.git
Merge branch 'master' of https://github.com/cocos2d/cocos2d-x
Conflicts: cocos2dx/include/CCNode.h
This commit is contained in:
commit
0378a6a36d
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -44,7 +45,7 @@ typedef struct _hashElement
|
|||
CCAction *currentAction;
|
||||
bool currentActionSalvaged;
|
||||
bool paused;
|
||||
UT_hash_handle hh;
|
||||
UT_hash_handle hh;
|
||||
} tHashElement;
|
||||
|
||||
CCActionManager* CCActionManager::sharedManager(void)
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -33,10 +34,10 @@ namespace cocos2d {
|
|||
// CCAtlasNode - Creation & Init
|
||||
|
||||
CCAtlasNode::CCAtlasNode()
|
||||
: m_nItemsPerRow(0)
|
||||
, m_nItemsPerColumn(0)
|
||||
, m_nItemWidth(0)
|
||||
, m_nItemHeight(0)
|
||||
: m_uItemsPerRow(0)
|
||||
, m_uItemsPerColumn(0)
|
||||
, m_uItemWidth(0)
|
||||
, m_uItemHeight(0)
|
||||
, m_pTextureAtlas(NULL)
|
||||
, m_bIsOpacityModifyRGB(false)
|
||||
, m_cOpacity(0)
|
||||
|
@ -48,7 +49,8 @@ CCAtlasNode::~CCAtlasNode()
|
|||
CC_SAFE_RELEASE(m_pTextureAtlas);
|
||||
}
|
||||
|
||||
CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight,
|
||||
unsigned int itemsToRender)
|
||||
{
|
||||
CCAtlasNode * pRet = new CCAtlasNode();
|
||||
if (pRet->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender))
|
||||
|
@ -60,11 +62,12 @@ CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, int tileWidth, in
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight,
|
||||
unsigned int itemsToRender)
|
||||
{
|
||||
assert(tile != NULL);
|
||||
m_nItemWidth = (int) (tileWidth * CC_CONTENT_SCALE_FACTOR());
|
||||
m_nItemHeight = (int) (tileHeight * CC_CONTENT_SCALE_FACTOR());
|
||||
m_uItemWidth = (int) (tileWidth * CC_CONTENT_SCALE_FACTOR());
|
||||
m_uItemHeight = (int) (tileHeight * CC_CONTENT_SCALE_FACTOR());
|
||||
|
||||
m_cOpacity = 255;
|
||||
m_tColor = m_tColorUnmodified = ccWHITE;
|
||||
|
@ -99,8 +102,8 @@ bool CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int tileHeig
|
|||
void CCAtlasNode::calculateMaxItems()
|
||||
{
|
||||
CCSize s = m_pTextureAtlas->getTexture()->getContentSizeInPixels();
|
||||
m_nItemsPerColumn = (int)(s.height / m_nItemHeight);
|
||||
m_nItemsPerRow = (int)(s.width / m_nItemWidth);
|
||||
m_uItemsPerColumn = (int)(s.height / m_uItemHeight);
|
||||
m_uItemsPerRow = (int)(s.width / m_uItemWidth);
|
||||
}
|
||||
|
||||
void CCAtlasNode::updateAtlasValues()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -43,7 +44,7 @@ THE SOFTWARE.
|
|||
namespace cocos2d {
|
||||
|
||||
CCNode::CCNode(void)
|
||||
: m_nZOrder(0)
|
||||
: m_uZOrder(0)
|
||||
, m_fVertexZ(0.0f)
|
||||
, m_fRotation(0.0f)
|
||||
, m_fScaleX(1.0f)
|
||||
|
@ -69,6 +70,8 @@ CCNode::CCNode(void)
|
|||
, m_pUserData(NULL)
|
||||
, m_bIsTransformDirty(true)
|
||||
, m_bIsInverseDirty(true)
|
||||
, m_fSkewX(0.0)
|
||||
, m_fSkewY(0.0)
|
||||
#ifdef CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||
, m_bIsTransformGLDirty(true)
|
||||
#endif
|
||||
|
@ -118,17 +121,46 @@ void CCNode::arrayMakeObjectsPerformSelector(CCArray* pArray, callbackFunc func)
|
|||
}
|
||||
}
|
||||
|
||||
/// zOrder getter
|
||||
int CCNode::getZOrder()
|
||||
float CCNode::getSkewX()
|
||||
{
|
||||
return m_nZOrder;
|
||||
return m_fSkewX;
|
||||
}
|
||||
|
||||
void CCNode::setSkewX(float newSkewX)
|
||||
{
|
||||
m_fSkewX = newSkewX;
|
||||
m_bIsTransformDirty = m_bIsInverseDirty = true;
|
||||
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||
m_bIsTransformGLDirty = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
float CCNode::getSkewY()
|
||||
{
|
||||
return m_fSkewY;
|
||||
m_bIsTransformDirty = m_bIsInverseDirty = true;
|
||||
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||
m_bIsTransformGLDirty = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CCNode::setSkewY(float newSkewY)
|
||||
{
|
||||
m_fSkewY = newSkewY;
|
||||
|
||||
}
|
||||
|
||||
/// zOrder getter
|
||||
unsigned int CCNode::getZOrder()
|
||||
{
|
||||
return m_uZOrder;
|
||||
}
|
||||
|
||||
/// zOrder setter : private method
|
||||
/// used internally to alter the zOrder variable. DON'T call this method manually
|
||||
void CCNode::setZOrder(int z)
|
||||
void CCNode::setZOrder(unsigned int z)
|
||||
{
|
||||
m_nZOrder = z;
|
||||
m_uZOrder = z;
|
||||
}
|
||||
|
||||
/// ertexZ getter
|
||||
|
@ -161,38 +193,6 @@ void CCNode::setRotation(float newRotation)
|
|||
#endif
|
||||
}
|
||||
|
||||
/// SkewX getter
|
||||
float CCNode::getSkewX()
|
||||
{
|
||||
return m_fSkewX;
|
||||
}
|
||||
|
||||
/// SkewX setter
|
||||
void CCNode::setSkewX(float newSkewX)
|
||||
{
|
||||
m_fSkewX = newSkewX;
|
||||
m_bIsTransformDirty = m_bIsInverseDirty = true;
|
||||
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||
m_bIsTransformGLDirty = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// SkewY getter
|
||||
float CCNode::getSkewY()
|
||||
{
|
||||
return m_fSkewY;
|
||||
}
|
||||
|
||||
/// SkewY setter
|
||||
void CCNode::setSkewY(float newSkewY)
|
||||
{
|
||||
m_fSkewY = newSkewY;
|
||||
m_bIsTransformDirty = m_bIsInverseDirty = true;
|
||||
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||
m_bIsTransformGLDirty = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// scale getter
|
||||
float CCNode::getScale(void)
|
||||
{
|
||||
|
@ -526,7 +526,7 @@ void CCNode::childrenAlloc(void)
|
|||
m_pChildren->retain();
|
||||
}
|
||||
|
||||
CCNode* CCNode::getChildByTag(int aTag)
|
||||
CCNode* CCNode::getChildByTag(unsigned int aTag)
|
||||
{
|
||||
CCAssert( aTag != kCCNodeTagInvalid, "Invalid tag");
|
||||
|
||||
|
@ -547,7 +547,7 @@ CCNode* CCNode::getChildByTag(int aTag)
|
|||
* If a class want's to extend the 'addChild' behaviour it only needs
|
||||
* to override this method
|
||||
*/
|
||||
void CCNode::addChild(CCNode *child, int zOrder, int tag)
|
||||
void CCNode::addChild(CCNode *child, unsigned int zOrder, int tag)
|
||||
{
|
||||
CCAssert( child != NULL, "Argument must be non-nil");
|
||||
CCAssert( child->m_pParent == NULL, "child already added. It can't be added again");
|
||||
|
@ -570,7 +570,7 @@ void CCNode::addChild(CCNode *child, int zOrder, int tag)
|
|||
}
|
||||
}
|
||||
|
||||
void CCNode::addChild(CCNode *child, int zOrder)
|
||||
void CCNode::addChild(CCNode *child, unsigned int zOrder)
|
||||
{
|
||||
CCAssert( child != NULL, "Argument must be non-nil");
|
||||
this->addChild(child, zOrder, child->m_nTag);
|
||||
|
@ -579,7 +579,7 @@ void CCNode::addChild(CCNode *child, int zOrder)
|
|||
void CCNode::addChild(CCNode *child)
|
||||
{
|
||||
CCAssert( child != NULL, "Argument must be non-nil");
|
||||
this->addChild(child, child->m_nZOrder, child->m_nTag);
|
||||
this->addChild(child, child->m_uZOrder, child->m_nTag);
|
||||
}
|
||||
|
||||
void CCNode::removeFromParentAndCleanup(bool cleanup)
|
||||
|
@ -605,7 +605,7 @@ void CCNode::removeChild(CCNode* child, bool cleanup)
|
|||
}
|
||||
}
|
||||
|
||||
void CCNode::removeChildByTag(int tag, bool cleanup)
|
||||
void CCNode::removeChildByTag(unsigned int tag, bool cleanup)
|
||||
{
|
||||
CCAssert( tag != kCCNodeTagInvalid, "Invalid tag");
|
||||
|
||||
|
@ -679,7 +679,7 @@ void CCNode::detachChild(CCNode *child, bool doCleanup)
|
|||
|
||||
|
||||
// helper used by reorderChild & add
|
||||
void CCNode::insertChild(CCNode* child, int z)
|
||||
void CCNode::insertChild(CCNode* child, unsigned int z)
|
||||
{
|
||||
unsigned int index = 0;
|
||||
CCNode* a = (CCNode*) m_pChildren->lastObject();
|
||||
|
@ -693,7 +693,7 @@ void CCNode::insertChild(CCNode* child, int z)
|
|||
CCARRAY_FOREACH(m_pChildren, pObject)
|
||||
{
|
||||
CCNode* pNode = (CCNode*) pObject;
|
||||
if ( pNode && (pNode->m_nZOrder > z ))
|
||||
if ( pNode && (pNode->m_uZOrder > z ))
|
||||
{
|
||||
m_pChildren->insertObject(child, index);
|
||||
break;
|
||||
|
@ -705,7 +705,7 @@ void CCNode::insertChild(CCNode* child, int z)
|
|||
child->setZOrder(z);
|
||||
}
|
||||
|
||||
void CCNode::reorderChild(CCNode *child, int zOrder)
|
||||
void CCNode::reorderChild(CCNode *child, unsigned int zOrder)
|
||||
{
|
||||
CCAssert( child != NULL, "Child must be non-nil");
|
||||
|
||||
|
@ -752,7 +752,7 @@ void CCNode::visit()
|
|||
{
|
||||
pNode = (CCNode*) arrayData->arr[i];
|
||||
|
||||
if ( pNode && pNode->m_nZOrder < 0 )
|
||||
if ( pNode && pNode->m_uZOrder < 0 )
|
||||
{
|
||||
pNode->visit();
|
||||
}
|
||||
|
@ -852,6 +852,15 @@ void CCNode::transform()
|
|||
if (m_fRotation != 0.0f )
|
||||
glRotatef( -m_fRotation, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
// skew
|
||||
if ( (skewX_ != 0.0f) || (skewY_ != 0.0f) )
|
||||
{
|
||||
CCAffineTransform skewMatrix = CCAffineTransformMake( 1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f );
|
||||
GLfloat glMatrix[16];
|
||||
CCAffineToGL(&skewMatrix, glMatrix);
|
||||
glMultMatrixf(glMatrix);
|
||||
}
|
||||
|
||||
// scale
|
||||
if (m_fScaleX != 1.0f || m_fScaleY != 1.0f)
|
||||
glScalef( m_fScaleX, m_fScaleY, 1.0f );
|
||||
|
@ -909,19 +918,19 @@ void CCNode::stopAction(CCAction* action)
|
|||
CCActionManager::sharedManager()->removeAction(action);
|
||||
}
|
||||
|
||||
void CCNode::stopActionByTag(int tag)
|
||||
void CCNode::stopActionByTag(unsigned int tag)
|
||||
{
|
||||
CCAssert( tag != kCCActionTagInvalid, "Invalid tag");
|
||||
CCActionManager::sharedManager()->removeActionByTag(tag, this);
|
||||
}
|
||||
|
||||
CCAction * CCNode::getActionByTag(int tag)
|
||||
CCAction * CCNode::getActionByTag(unsigned int tag)
|
||||
{
|
||||
CCAssert( tag != kCCActionTagInvalid, "Invalid tag");
|
||||
return CCActionManager::sharedManager()->getActionByTag(tag, this);
|
||||
}
|
||||
|
||||
int CCNode::numberOfRunningActions()
|
||||
unsigned int CCNode::numberOfRunningActions()
|
||||
{
|
||||
return CCActionManager::sharedManager()->numberOfRunningActionsInTarget(this);
|
||||
}
|
||||
|
@ -933,7 +942,7 @@ void CCNode::scheduleUpdate()
|
|||
scheduleUpdateWithPriority(0);
|
||||
}
|
||||
|
||||
void CCNode::scheduleUpdateWithPriority(int priority)
|
||||
void CCNode::scheduleUpdateWithPriority(unsigned int priority)
|
||||
{
|
||||
CCScheduler::sharedScheduler()->scheduleUpdateForTarget(this, priority, !m_bIsRunning);
|
||||
}
|
||||
|
@ -994,22 +1003,42 @@ void CCNode::selectorProtocolRelease(void)
|
|||
|
||||
CCAffineTransform CCNode::nodeToParentTransform(void)
|
||||
{
|
||||
if ( m_bIsTransformDirty ) {
|
||||
if (m_bIsTransformDirty) {
|
||||
|
||||
m_tTransform = CCAffineTransformIdentity;
|
||||
|
||||
if( ! m_bIsRelativeAnchorPoint && ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero) )
|
||||
{
|
||||
m_tTransform = CCAffineTransformTranslate(m_tTransform, m_tAnchorPointInPixels.x, m_tAnchorPointInPixels.y);
|
||||
}
|
||||
|
||||
if( ! CCPoint::CCPointEqualToPoint(m_tPositionInPixels, CCPointZero) )
|
||||
if(! CCPoint::CCPointEqualToPoint(m_tPositionInPixels, CCPointZero))
|
||||
{
|
||||
m_tTransform = CCAffineTransformTranslate(m_tTransform, m_tPositionInPixels.x, m_tPositionInPixels.y);
|
||||
if( m_fRotation != 0 )
|
||||
m_tTransform = CCAffineTransformRotate(m_tTransform, -CC_DEGREES_TO_RADIANS(m_fRotation));
|
||||
if( ! (m_fScaleX == 1 && m_fScaleY == 1) )
|
||||
m_tTransform = CCAffineTransformScale(m_tTransform, m_fScaleX, m_fScaleY);
|
||||
}
|
||||
|
||||
if( ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero) )
|
||||
if(m_fRotation != 0)
|
||||
{
|
||||
m_tTransform = CCAffineTransformRotate(m_tTransform, -CC_DEGREES_TO_RADIANS(m_fRotation));
|
||||
}
|
||||
|
||||
if(m_fSkewX != 0 || m_fSkewY != 0)
|
||||
{
|
||||
// create a skewed coordinate system
|
||||
CCAffineTransform skew = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)), tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f, 0.0f, 0.0f);
|
||||
// apply the skew to the transform
|
||||
m_tTransform = CCAffineTransformConcat(skew, m_tTransform);
|
||||
}
|
||||
|
||||
if(! (m_fScaleX == 1 && m_fScaleY == 1))
|
||||
{
|
||||
m_tTransform = CCAffineTransformScale(m_tTransform, m_fScaleX, m_fScaleY);
|
||||
}
|
||||
|
||||
if(! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPixels, CCPointZero))
|
||||
{
|
||||
m_tTransform = CCAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);
|
||||
}
|
||||
|
||||
m_bIsTransformDirty = false;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -104,7 +105,7 @@ protected:
|
|||
*/
|
||||
CCNode *m_pTarget;
|
||||
/** The action tag. An identifier of the action */
|
||||
int m_nTag;
|
||||
int m_nTag;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
CCPoint m_startPosition;
|
||||
CCPoint m_delta;
|
||||
ccTime m_height;
|
||||
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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -95,10 +95,10 @@ namespace cocos2d
|
|||
static CCShuffleTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration);
|
||||
|
||||
protected:
|
||||
int m_nSeed;
|
||||
int m_nTilesCount;
|
||||
int *m_pTilesOrder;
|
||||
Tile *m_pTiles;
|
||||
int m_nSeed;
|
||||
unsigned int m_nTilesCount;
|
||||
int *m_pTilesOrder;
|
||||
Tile *m_pTiles;
|
||||
};
|
||||
|
||||
/** @brief CCFadeOutTRTiles action
|
||||
|
@ -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);
|
||||
|
||||
|
@ -182,9 +182,9 @@ namespace cocos2d
|
|||
static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration);
|
||||
|
||||
protected:
|
||||
int m_nSeed;
|
||||
int m_nTilesCount;
|
||||
int *m_pTilesOrder;
|
||||
int m_nSeed;
|
||||
unsigned int m_nTilesCount;
|
||||
int *m_pTilesOrder;
|
||||
};
|
||||
|
||||
/** @brief CCWavesTiles3D action. */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -47,14 +48,14 @@ class CC_DLL CCAtlasNode : public CCNode, public CCRGBAProtocol, public CCTextur
|
|||
protected:
|
||||
|
||||
//! chars per row
|
||||
int m_nItemsPerRow;
|
||||
unsigned int m_uItemsPerRow;
|
||||
//! chars per column
|
||||
int m_nItemsPerColumn;
|
||||
unsigned int m_uItemsPerColumn;
|
||||
|
||||
//! width of each char
|
||||
int m_nItemWidth;
|
||||
unsigned int m_uItemWidth;
|
||||
//! height of each char
|
||||
int m_nItemHeight;
|
||||
unsigned int m_uItemHeight;
|
||||
|
||||
ccColor3B m_tColorUnmodified;
|
||||
|
||||
|
@ -71,10 +72,11 @@ public:
|
|||
virtual ~CCAtlasNode();
|
||||
|
||||
/** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
static CCAtlasNode * atlasWithTileFile(const char* tile,int tileWidth, int tileHeight, int itemsToRender);
|
||||
static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight,
|
||||
unsigned int itemsToRender);
|
||||
|
||||
/** initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
bool initWithTileFile(const char* tile, int tileWidth, int tileHeight, int itemsToRender);
|
||||
bool initWithTileFile(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender);
|
||||
|
||||
/** updates the Atlas (indexed vertex array).
|
||||
* Shall be overriden in subclasses
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -108,7 +109,7 @@ namespace cocos2d {
|
|||
// variable property
|
||||
|
||||
/** The z order of the node relative to it's "brothers": children of the same parent */
|
||||
CC_PROPERTY_READONLY(int, m_nZOrder, ZOrder)
|
||||
CC_PROPERTY_READONLY(unsigned int, m_uZOrder, ZOrder)
|
||||
|
||||
/** The real openGL Z vertex.
|
||||
Differences between openGL Z vertex and cocos2d Z order:
|
||||
|
@ -140,17 +141,17 @@ namespace cocos2d {
|
|||
CC_PROPERTY(CCPoint, m_tPosition, Position)
|
||||
CC_PROPERTY(CCPoint, m_tPositionInPixels, PositionInPixels)
|
||||
|
||||
/** The X skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the X direction.
|
||||
Thus, it is the angle between the Y axis and the left edge of the shape
|
||||
The default skewX angle is 0. Positive values distort the node in a CW direction.
|
||||
/** The X skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the X direction.
|
||||
Thus, it is the angle between the Y axis and the left edge of the shape
|
||||
The default skewX angle is 0. Positive values distort the node in a CW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewX, SkewX)
|
||||
|
||||
/** The Y skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the Y direction.
|
||||
Thus, it is the angle between the X axis and the bottom edge of the shape
|
||||
The default skewY angle is 0. Positive values distort the node in a CCW direction.
|
||||
/** The Y skew angle of the node in degrees.
|
||||
This angle describes the shear distortion in the Y direction.
|
||||
Thus, it is the angle between the X axis and the bottom edge of the shape
|
||||
The default skewY angle is 0. Positive values distort the node in a CCW direction.
|
||||
*/
|
||||
CC_PROPERTY(float, m_fSkewY, SkewY)
|
||||
|
||||
|
@ -234,10 +235,10 @@ namespace cocos2d {
|
|||
void childrenAlloc(void);
|
||||
|
||||
//! helper that reorder a child
|
||||
void insertChild(CCNode* child, int z);
|
||||
void insertChild(CCNode* child, unsigned int z);
|
||||
|
||||
//! used internally to alter the zOrder variable. DON'T call this method manually
|
||||
void setZOrder(int z);
|
||||
void setZOrder(unsigned int z);
|
||||
|
||||
void detachChild(CCNode *child, bool doCleanup);
|
||||
|
||||
|
@ -276,7 +277,7 @@ namespace cocos2d {
|
|||
|
||||
/** callback that is called every time the CCNode leaves the 'stage'.
|
||||
If the CCNode leaves the 'stage' with a transition, this callback is called when the transition finishes.
|
||||
During onExit you can't a "sister/brother" node.
|
||||
During onExit you can't access a sibling node.
|
||||
*/
|
||||
virtual void onExit();
|
||||
|
||||
|
@ -292,13 +293,13 @@ namespace cocos2d {
|
|||
If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
@since v0.7.1
|
||||
*/
|
||||
virtual void addChild(CCNode * child, int zOrder);
|
||||
virtual void addChild(CCNode * child, unsigned int zOrder);
|
||||
|
||||
/** Adds a child to the container with z order and tag
|
||||
If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
@since v0.7.1
|
||||
*/
|
||||
virtual void addChild(CCNode * child, int zOrder, int tag);
|
||||
virtual void addChild(CCNode * child, unsigned int zOrder, int tag);
|
||||
|
||||
// composition: REMOVE
|
||||
|
||||
|
@ -316,7 +317,7 @@ namespace cocos2d {
|
|||
/** Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter
|
||||
@since v0.7.1
|
||||
*/
|
||||
void removeChildByTag(int tag, bool cleanup);
|
||||
void removeChildByTag(unsigned int tag, bool cleanup);
|
||||
|
||||
/** Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
|
||||
@since v0.7.1
|
||||
|
@ -328,12 +329,12 @@ namespace cocos2d {
|
|||
@return returns a CCNode object
|
||||
@since v0.7.1
|
||||
*/
|
||||
CCNode * getChildByTag(int tag);
|
||||
CCNode * getChildByTag(unsigned int tag);
|
||||
|
||||
/** Reorders a child according to a new z value.
|
||||
* The child MUST be already added.
|
||||
*/
|
||||
virtual void reorderChild(CCNode * child, int zOrder);
|
||||
virtual void reorderChild(CCNode * child, unsigned int zOrder);
|
||||
|
||||
/** Stops all running actions and schedulers
|
||||
@since v0.8
|
||||
|
@ -405,20 +406,20 @@ namespace cocos2d {
|
|||
/** Removes an action from the running action list given its tag
|
||||
@since v0.7.1
|
||||
*/
|
||||
void stopActionByTag(int tag);
|
||||
void stopActionByTag(unsigned int tag);
|
||||
|
||||
/** Gets an action from the running action list given its tag
|
||||
@since v0.7.1
|
||||
@return the Action the with the given tag
|
||||
*/
|
||||
CCAction* getActionByTag(int tag);
|
||||
CCAction* getActionByTag(unsigned int tag);
|
||||
|
||||
/** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
|
||||
* 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 numberOfRunningActions(void);
|
||||
unsigned int numberOfRunningActions(void);
|
||||
|
||||
|
||||
// timers
|
||||
|
@ -440,7 +441,7 @@ namespace cocos2d {
|
|||
|
||||
@since v0.99.3
|
||||
*/
|
||||
void scheduleUpdateWithPriority(int priority);
|
||||
void scheduleUpdateWithPriority(unsigned int priority);
|
||||
|
||||
/* unschedules the "update" method.
|
||||
|
||||
|
|
|
@ -75,20 +75,20 @@ namespace cocos2d{
|
|||
|
||||
for( int i=0; i<n; i++) {
|
||||
unsigned char a = s[i] - m_cMapStartChar;
|
||||
float row = (float) (a % m_nItemsPerRow);
|
||||
float col = (float) (a / m_nItemsPerRow);
|
||||
float row = (float) (a % m_uItemsPerRow);
|
||||
float col = (float) (a / m_uItemsPerRow);
|
||||
|
||||
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
// Issue #938. Don't use texStepX & texStepY
|
||||
float left = (2 * row * m_nItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_nItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_nItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_nItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
#else
|
||||
float left = row * m_nItemWidth / textureWide;
|
||||
float right = left + m_nItemWidth / textureWide;
|
||||
float top = col * m_nItemHeight / textureHigh;
|
||||
float bottom = top + m_nItemHeight / textureHigh;
|
||||
float left = row * m_uItemWidth / textureWide;
|
||||
float right = left + m_uItemWidth / textureWide;
|
||||
float top = col * m_uItemHeight / textureHigh;
|
||||
float bottom = top + m_uItemHeight / textureHigh;
|
||||
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
|
||||
quad.tl.texCoords.u = left;
|
||||
|
@ -100,17 +100,17 @@ namespace cocos2d{
|
|||
quad.br.texCoords.u = right;
|
||||
quad.br.texCoords.v = bottom;
|
||||
|
||||
quad.bl.vertices.x = (float) (i * m_nItemWidth);
|
||||
quad.bl.vertices.x = (float) (i * m_uItemWidth);
|
||||
quad.bl.vertices.y = 0;
|
||||
quad.bl.vertices.z = 0.0f;
|
||||
quad.br.vertices.x = (float)(i * m_nItemWidth + m_nItemWidth);
|
||||
quad.br.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
|
||||
quad.br.vertices.y = 0;
|
||||
quad.br.vertices.z = 0.0f;
|
||||
quad.tl.vertices.x = (float)(i * m_nItemWidth);
|
||||
quad.tl.vertices.y = (float)(m_nItemHeight);
|
||||
quad.tl.vertices.x = (float)(i * m_uItemWidth);
|
||||
quad.tl.vertices.y = (float)(m_uItemHeight);
|
||||
quad.tl.vertices.z = 0.0f;
|
||||
quad.tr.vertices.x = (float)(i * m_nItemWidth + m_nItemWidth);
|
||||
quad.tr.vertices.y = (float)(m_nItemHeight);
|
||||
quad.tr.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth);
|
||||
quad.tr.vertices.y = (float)(m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
m_pTextureAtlas->updateQuad(&quad, i);
|
||||
|
@ -129,8 +129,8 @@ namespace cocos2d{
|
|||
this->updateAtlasValues();
|
||||
|
||||
CCSize s;
|
||||
s.width = (float)(m_sString.length() * m_nItemWidth);
|
||||
s.height = (float)(m_nItemHeight);
|
||||
s.width = (float)(m_sString.length() * m_uItemWidth);
|
||||
s.height = (float)(m_uItemHeight);
|
||||
this->setContentSizeInPixels(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace cocos2d {
|
|||
{
|
||||
m_pPosToAtlasIndex = new StringToIntegerDictionary();
|
||||
this->updateAtlasValues();
|
||||
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_nItemWidth),
|
||||
(float)(m_pTGAInfo->height*m_nItemHeight)));
|
||||
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_uItemWidth),
|
||||
(float)(m_pTGAInfo->height*m_uItemHeight)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -180,22 +180,22 @@ namespace cocos2d {
|
|||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
float row = (float) (value.r % m_nItemsPerRow);
|
||||
float col = (float) (value.r / m_nItemsPerRow);
|
||||
float row = (float) (value.r % m_uItemsPerRow);
|
||||
float col = (float) (value.r / m_uItemsPerRow);
|
||||
|
||||
float textureWide = (float) (m_pTextureAtlas->getTexture()->getPixelsWide());
|
||||
float textureHigh = (float) (m_pTextureAtlas->getTexture()->getPixelsHigh());
|
||||
|
||||
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
float left = (2 * row * m_nItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_nItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_nItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_nItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
#else
|
||||
float left = (row * m_nItemWidth) / textureWide;
|
||||
float right = left + m_nItemWidth / textureWide;
|
||||
float top = (col * m_nItemHeight) / textureHigh;
|
||||
float bottom = top + m_nItemHeight / textureHigh;
|
||||
float left = (row * m_uItemWidth) / textureWide;
|
||||
float right = left + m_uItemWidth / textureWide;
|
||||
float top = (col * m_uItemHeight) / textureHigh;
|
||||
float bottom = top + m_uItemHeight / textureHigh;
|
||||
#endif
|
||||
|
||||
quad.tl.texCoords.u = left;
|
||||
|
@ -207,17 +207,17 @@ namespace cocos2d {
|
|||
quad.br.texCoords.u = right;
|
||||
quad.br.texCoords.v = bottom;
|
||||
|
||||
quad.bl.vertices.x = (float) (x * m_nItemWidth);
|
||||
quad.bl.vertices.y = (float) (y * m_nItemHeight);
|
||||
quad.bl.vertices.x = (float) (x * m_uItemWidth);
|
||||
quad.bl.vertices.y = (float) (y * m_uItemHeight);
|
||||
quad.bl.vertices.z = 0.0f;
|
||||
quad.br.vertices.x = (float)(x * m_nItemWidth + m_nItemWidth);
|
||||
quad.br.vertices.y = (float)(y * m_nItemHeight);
|
||||
quad.br.vertices.x = (float)(x * m_uItemWidth + m_uItemWidth);
|
||||
quad.br.vertices.y = (float)(y * m_uItemHeight);
|
||||
quad.br.vertices.z = 0.0f;
|
||||
quad.tl.vertices.x = (float)(x * m_nItemWidth);
|
||||
quad.tl.vertices.y = (float)(y * m_nItemHeight + m_nItemHeight);
|
||||
quad.tl.vertices.x = (float)(x * m_uItemWidth);
|
||||
quad.tl.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
|
||||
quad.tl.vertices.z = 0.0f;
|
||||
quad.tr.vertices.x = (float)(x * m_nItemWidth + m_nItemWidth);
|
||||
quad.tr.vertices.y = (float)(y * m_nItemHeight + m_nItemHeight);
|
||||
quad.tr.vertices.x = (float)(x * m_uItemWidth + m_uItemWidth);
|
||||
quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
m_pTextureAtlas->updateQuad(&quad, index);
|
||||
|
|
Loading…
Reference in New Issue