Merge remote branch 'origin/master'

This commit is contained in:
Walzer 2011-07-04 16:25:29 +08:00
commit 80c819d8b6
73 changed files with 945 additions and 489 deletions

View File

@ -95,6 +95,17 @@ public class Cocos2dxSound {
return INVALID_SOUND_ID;
}
/*
* Someone reports that, it can not play effect for the
* first time. If you are lucky to meet it. There are two
* ways to resolve it.
* 1. Add some delay here. I don't know how long it is, so
* I don't add it here.
* 2. If you use 2.2(API level 8), you can call
* SoundPool.setOnLoadCompleteListener() to play the effect.
* Because the method is supported from 2.2, so I can't use
* it here.
*/
playEffect(path);
}

View File

@ -1 +1 @@
ef3209421ade100cd309997e03cf355267873227
28cb6dce5b3f9c570ba1976b950bc35a524008f6

View File

@ -95,6 +95,17 @@ public class Cocos2dxSound {
return INVALID_SOUND_ID;
}
/*
* Someone reports that, it can not play effect for the
* first time. If you are lucky to meet it. There are two
* ways to resolve it.
* 1. Add some delay here. I don't know how long it is, so
* I don't add it here.
* 2. If you use 2.2(API level 8), you can call
* SoundPool.setOnLoadCompleteListener() to play the effect.
* Because the method is supported from 2.2, so I can't use
* it here.
*/
playEffect(path);
}

View File

@ -1 +1 @@
962d2c2b08376b49464eb835cda18d14da1678e1
9fb28c61f00c78e9def984ba0b22cf9fae814b94

View File

@ -73,7 +73,6 @@ sprite_nodes/CCSprite.cpp \
sprite_nodes/CCSpriteBatchNode.cpp \
sprite_nodes/CCSpriteFrame.cpp \
sprite_nodes/CCSpriteFrameCache.cpp \
sprite_nodes/CCSpriteSheet.cpp \
support/CCArray.cpp \
support/CCProfiling.cpp \
support/CCPointExtension.cpp \

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
@ -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);

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
@ -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()

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
@ -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,7 +193,6 @@ void CCNode::setRotation(float newRotation)
#endif
}
/// scale getter
float CCNode::getScale(void)
{
@ -495,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");
@ -516,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");
@ -539,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);
@ -548,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)
@ -574,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");
@ -648,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();
@ -662,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;
@ -674,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");
@ -721,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();
}
@ -821,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 );
@ -878,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);
}
@ -902,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);
}
@ -963,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;
}

View File

@ -110,8 +110,8 @@ namespace cocos2d
CCDirector *pDirector = CCDirector::sharedDirector();
CCSize s = pDirector->getWinSizeInPixels();
unsigned int POTWide = ccNextPOT((unsigned int)s.width);
unsigned int POTHigh = ccNextPOT((unsigned int)s.height);
unsigned long POTWide = ccNextPOT((unsigned int)s.width);
unsigned long POTHigh = ccNextPOT((unsigned int)s.height);
CCTexture2DPixelFormat format = pDirector->getPiexFormat() == kCCPixelFormatRGB565 ? kCCTexture2DPixelFormat_RGB565 : kCCTexture2DPixelFormat_RGBA8888;
@ -346,7 +346,7 @@ namespace cocos2d
glVertexPointer(3, GL_FLOAT, 0, m_pVertices);
glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates);
glDrawElements(GL_TRIANGLES, n * 6, GL_UNSIGNED_SHORT, m_pIndices);
glDrawElements(GL_TRIANGLES, (GLsizei)n * 6, GL_UNSIGNED_SHORT, m_pIndices);
// restore GL default state
glEnableClientState(GL_COLOR_ARRAY);
@ -521,7 +521,7 @@ namespace cocos2d
glVertexPointer(3, GL_FLOAT, 0, m_pVertices);
glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates);
glDrawElements(GL_TRIANGLES, n*6, GL_UNSIGNED_SHORT, m_pIndices);
glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, m_pIndices);
// restore default GL state
glEnableClientState(GL_COLOR_ARRAY);

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
*/
@ -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;
};

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;
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.

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);
@ -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. */

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) 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
@ -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

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

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
@ -179,9 +180,9 @@ namespace cocos2d{
virtual void setAnchorPoint(CCPoint var);
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
#if CC_BITMAPFONTATLAS_DEBUG_DRAW
#if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw();
#endif // CC_BITMAPFONTATLAS_DEBUG_DRAW
#endif // CC_LABELBMFONT_DEBUG_DRAW
private:
char * atlasNameFromFntFile(const char *fntFile);
int kerningAmountForFirst(unsigned short first, unsigned short second);

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
@ -132,8 +133,8 @@ All features from CCLayer are valid, plus the following new features:
class CC_DLL CCLayerColor : public CCLayer , public CCRGBAProtocol, public CCBlendProtocol
{
protected:
GLfloat m_pSquareVertices[4 * 2];
GLubyte m_pSquareColors[4 * 4];
ccVertex2F m_pSquareVertices[4];
ccColor4B m_pSquareColors[4];
public:
@ -195,16 +196,18 @@ the background.
All features from CCLayerColor are valid, plus the following new features:
- direction
- final color
- interpolation mode
Color is interpolated between the startColor and endColor along the given
vector (starting at the origin, ending at the terminus). If no vector is
supplied, it defaults to (0, -1) -- a fade from top to bottom.
Given the nature of
the interpolation, you will not see either the start or end color for
If 'compressedInterpolation' is disabled, you will not see either the start or end color for
non-cardinal vectors; a smooth gradient implying both end points will be still
be drawn, however.
If ' compressedInterpolation' is enabled (default mode) you will see both the start and end colors of the gradient.
@since v0.99.5
*/
class CC_DLL CCLayerGradient : public CCLayerColor
@ -222,14 +225,17 @@ public:
/** Initializes the CCLayer with a gradient between start and end in the direction of v. */
virtual bool initWithColor(ccColor4B start, ccColor4B end, CCPoint v);
ccColor3B getStartColor();
void setStartColor(ccColor3B colors);
CC_PROPERTY(ccColor3B, m_startColor, StartColor)
CC_PROPERTY(ccColor3B, m_endColor, EndColor)
CC_PROPERTY(GLubyte, m_cStartOpacity, StartOpacity)
CC_PROPERTY(GLubyte, m_cEndOpacity, EndOpacity)
CC_PROPERTY(CCPoint, m_AlongVector, Vector)
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
Default: YES
*/
CC_PROPERTY(bool, m_bCompressedInterpolation, IsCompressedInterpolation)
LAYER_NODE_FUNC(CCLayerGradient);
protected:
virtual void updateColor();
@ -240,24 +246,24 @@ Features:
- It supports one or more children
- Only one children will be active a time
*/
class CC_DLL CCMultiplexLayer : public CCLayer
class CC_DLL CCLayerMultiplex : public CCLayer
{
protected:
unsigned int m_nEnabledLayer;
CCMutableArray<CCLayer *> * m_pLayers;
public:
CCMultiplexLayer();
virtual ~CCMultiplexLayer();
CCLayerMultiplex();
virtual ~CCLayerMultiplex();
/** creates a CCMultiplexLayer with one or more layers using a variable argument list. */
static CCMultiplexLayer * layerWithLayers(CCLayer* layer, ... );
/** creates a CCLayerMultiplex with one or more layers using a variable argument list. */
static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... );
/**
* lua script can not init with undetermined number of variables
* so add these functinons to be used with lua.
*/
static CCMultiplexLayer * layerWithLayer(CCLayer* layer);
static CCLayerMultiplex * layerWithLayer(CCLayer* layer);
void addLayer(CCLayer* layer);
bool initWithLayer(CCLayer* layer);
@ -272,7 +278,16 @@ public:
*/
void switchToAndReleaseMe(unsigned int n);
LAYER_NODE_FUNC(CCMultiplexLayer);
LAYER_NODE_FUNC(CCLayerMultiplex);
};
/** CCMultiplexLayer
It is the same as CCLayerMultiplex.
@deprecated Use CCLayerMultiplex instead. This class will be removed in v1.0.1
*/
class CCMultiplexLayer : public CCLayerMultiplex
{
};
}//namespace cocos2d

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
@ -100,6 +101,8 @@ namespace cocos2d{
virtual ~CCMenuItemLabel();
/** creates a CCMenuItemLabel with a Label, target and selector */
static CCMenuItemLabel * itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MenuHandler selector);
/** creates a CCMenuItemLabel with a Label. Target and selector will be nill */
static CCMenuItemLabel* itemWithLabel(CCNode *label);
/** initializes a CCMenuItemLabel with a Label, target and selector */
bool initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MenuHandler selector);
/** sets a new string to the inner label */

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
@ -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,6 +141,20 @@ 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.
*/
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.
*/
CC_PROPERTY(float, m_fSkewY, SkewY)
CC_PROPERTY_READONLY(CCArray*, m_pChildren, Children)
/** A CCCamera object that lets you move the node using a gluLookAt
@ -220,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);
@ -262,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();
@ -278,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
@ -302,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
@ -314,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
@ -391,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
@ -426,7 +441,7 @@ namespace cocos2d {
@since v0.99.3
*/
void scheduleUpdateWithPriority(int priority);
void scheduleUpdateWithPriority(unsigned int priority);
/* unschedules the "update" method.

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -49,9 +50,9 @@ namespace cocos2d {
CCParallaxNode();
virtual ~CCParallaxNode();
static CCParallaxNode * node();
virtual void addChild(CCNode * child, int z, CCPoint parallaxRatio, CCPoint positionOffset);
virtual void addChild(CCNode * child, unsigned int z, CCPoint parallaxRatio, CCPoint positionOffset);
// super methods
virtual void addChild(CCNode * child, int zOrder, int tag);
virtual void addChild(CCNode * child, unsigned int zOrder, int tag);
virtual void removeChild(CCNode* child, bool cleanup);
virtual void removeAllChildrenWithCleanup(bool cleanup);
virtual void visit(void);

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
@ -36,8 +37,6 @@ THE SOFTWARE.
namespace cocos2d {
class CCSpriteBatchNode;
class CCSpriteSheet;
class CCSpriteSheetInternalOnly;
class CCSpriteFrame;
class CCAnimation;
class CCRect;
@ -64,9 +63,11 @@ typedef enum {
CC_HONOR_PARENT_TRANSFORM_ROTATE = 1 << 1,
//! Scale with it's parent
CC_HONOR_PARENT_TRANSFORM_SCALE = 1 << 2,
//! Skew with it's parent
CC_HONOR_PARENT_TRANSFORM_SKEW = 1 << 3,
//! All possible transformation enabled. Default value.
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE,
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE | CC_HONOR_PARENT_TRANSFORM_SKEW,
} ccHonorParentTransform;
@ -195,8 +196,6 @@ public:
*/
static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect);
static CCSprite* spriteWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect);
public:
bool init(void);
virtual ~CCSprite(void);
@ -213,6 +212,8 @@ public:
virtual void setPosition(CCPoint pos);
virtual void setPositionInPixels(CCPoint pos);
virtual void setRotation(float fRotation);
virtual void setSkewX(float sx);
virtual void setSkewY(float sy);
virtual void setScaleX(float fScaleX);
virtual void setScaleY(float fScaleY);
virtual void setScale(float fScale);
@ -288,11 +289,10 @@ public:
*/
bool initWithFile(const char *pszFilename, CCRect rect);
/** Initializes an sprite with an CCSpriteSheet and a rect in points */
/** Initializes an sprite with an CCSpriteBatchNode and a rect in points */
bool initWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect);
bool initWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect);
/** Initializes an sprite with an CCSpriteSheet and a rect in pixels
/** Initializes an sprite with an CCSpriteBatchNode and a rect in pixels
@since v0.99.5
*/
bool initWithBatchNodeRectInPixels(CCSpriteBatchNode *batchNode, CCRect rect);
@ -318,7 +318,6 @@ public:
@since v0.99.0
*/
void useBatchNode(CCSpriteBatchNode *batchNode);
void useSpriteSheetRender(CCSpriteSheetInternalOnly *pSpriteSheet);
// Frames

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (C) 2009 Matt Oswald
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) 2008-2011 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -53,7 +54,7 @@ public:
// attributes
inline CCRect getRectInPixels(void) { return m_obRectInPixels; }
inline void setRectInPixels(CCRect rectInPixels) { m_obRectInPixels = rectInPixels; }
void setRectInPixels(CCRect rectInPixels);
inline bool isRotated(void) { return m_bRotated; }
inline void setRotated(bool bRotated) { m_bRotated = bRotated; }
@ -61,7 +62,7 @@ public:
/** get rect of the frame */
inline CCRect getRect(void) { return m_obRect; }
/** set rect of the frame */
inline void setRect(CCRect rect) { m_obRect = rect; }
void setRect(CCRect rect);
/** get offset of the frame */
inline CCPoint getOffsetInPixels(void) { return m_obOffsetInPixels; }

View File

@ -3,6 +3,7 @@ Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2009 Jason Booth
Copyright (c) 2009 Robert J Payne
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org

View File

@ -1,62 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (C) 2009 Matt Oswald
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __SPRITE_CCSPRITE_SHEET_H__
#define __SPRITE_CCSPRITE_SHEET_H__
#include "CCSpriteBatchNode.h"
namespace cocos2d {
/* Added only to prevent GCC compile warnings
Will be removed in v1.1
*/
class CC_DLL CCSpriteSheetInternalOnly : public CCSpriteBatchNode
{
};
/** @brief CCSpriteSheet is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
* (often known as "batch draw").
*
* A CCSpriteSheet can reference one and only one texture (one image file, one texture atlas).
* Only the CCSprites that are contained in that texture can be added to the CCSpriteSheet.
* All CCSprites added to a CCSpriteSheet are drawn in one OpenGL ES draw call.
* If the CCSprites are not added to a CCSpriteSheet then an OpenGL ES draw call will be needed for each one, which is less efficient.
*
*
* Limitations:
* - The only object that is accepted as child (or grandchild) is CCSprite or any subclass of CCSprite. eg: particles, labels and layer can't be added to a CCSpriteSheet.
* - Either all its children are Aliased or Antialiased. It can't be a mix. This is because "alias" is a property of the texture, and all the sprites share the same texture.
*
* @since v0.7.1
* @deprecated Use CCSpriteBatchNode instead. This class will be removed in v1.1
*/
class CC_DLL CCSpriteSheet: public CCSpriteSheetInternalOnly
{
};
}//namespace cocos2d
#endif // __SPRITE_CCSPRITE_SHEET_H__

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -70,7 +71,7 @@ namespace cocos2d {
/** Tilset information for the layer */
CC_PROPERTY(CCTMXTilesetInfo*, m_pTileSet, TileSet);
/** Layer orientation, which is the same as the map orientation */
CC_SYNTHESIZE(int, m_nLayerOrientation, LayerOrientation);
CC_SYNTHESIZE(unsigned int, m_uLayerOrientation, LayerOrientation);
/** properties from the layer. They can be added using Tiled */
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
public:

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
Copyright (c) 2010 Neophit
Copyright (c) 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) 2009-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) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -48,6 +49,7 @@ namespace cocos2d {
TMXLayerAttribNone = 1 << 0,
TMXLayerAttribBase64 = 1 << 1,
TMXLayerAttribGzip = 1 << 2,
TMXLayerAttribZlib = 1 << 3,
};
enum {

View File

@ -141,6 +141,13 @@ public:
*/
void drawNumberOfQuads(unsigned int n);
/** draws n quads from an index (offset).
n + start can't be greater than the capacity of the atlas
@since v1.0
*/
void drawNumberOfQuads(unsigned int n, unsigned int start);
/** draws all the Atlas's Quads
*/
void drawQuads();

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
@ -75,7 +76,7 @@ namespace cocos2d {
private:
void loadTGAfile(const char *file);
void calculateItemsToRender();
void updateAtlasValueAt(ccGridSize pos, ccColor3B value, int index);
void updateAtlasValueAt(ccGridSize pos, ccColor3B value, unsigned int index);
void updateAtlasValues();
protected:

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

@ -231,13 +231,13 @@ To enable set it to a value different than 0. Disabled by default.
*/
#define CC_SPRITEBATCHNODE_DEBUG_DRAW 0
/** @def CC_BITMAPFONTATLAS_DEBUG_DRAW
/** @def CC_LABELBMFONT_DEBUG_DRAW
If enabled, all subclasses of BitmapFontAtlas will draw a bounding box
Useful for debugging purposes only. It is recommened to leave it disabled.
To enable set it to a value different than 0. Disabled by default.
*/
#define CC_BITMAPFONTATLAS_DEBUG_DRAW 0
#define CC_LABELBMFONT_DEBUG_DRAW 0
/** @def CC_LABELATLAS_DEBUG_DRAW
If enabled, all subclasses of LabeltAtlas will draw a bounding box

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
@ -75,20 +76,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 +101,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);
@ -120,17 +121,18 @@ namespace cocos2d{
//CCLabelAtlas - CCLabelProtocol
void CCLabelAtlas::setString(const char *label)
{
if (strlen(label) > m_pTextureAtlas->getTotalQuads())
unsigned int len = strlen(label);
if (len > m_pTextureAtlas->getTotalQuads())
{
m_pTextureAtlas->resizeCapacity(strlen(label));
m_pTextureAtlas->resizeCapacity(len);
}
m_sString.clear();
m_sString = label;
this->updateAtlasValues();
CCSize s;
s.width = (float)(m_sString.length() * m_nItemWidth);
s.height = (float)(m_nItemHeight);
s.width = (float)(len * m_uItemWidth);
s.height = (float)(m_uItemHeight);
this->setContentSizeInPixels(s);
}
@ -159,7 +161,7 @@ namespace cocos2d{
glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
}
m_pTextureAtlas->drawNumberOfQuads(m_sString.length());
m_pTextureAtlas->drawNumberOfQuads(m_sString.length(), 0);
if( newBlend )
glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);

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
@ -486,7 +487,7 @@ namespace cocos2d{
if( ! fontChar )
{
fontChar = new CCSprite();
fontChar->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
fontChar->initWithBatchNode(this, rect);
this->addChild(fontChar, 0, i);
fontChar->release();
}
@ -643,7 +644,7 @@ namespace cocos2d{
}
//BitmapFontAtlas - Debug draw
#if CC_BITMAPFONTATLAS_DEBUG_DRAW
#if CC_LABELBMFONT_DEBUG_DRAW
void CCLabelBMFont::draw()
{
CCSpriteBatchNode::draw();
@ -654,6 +655,6 @@ namespace cocos2d{
};
ccDrawPoly(vertices, 4, true);
}
#endif // CC_BITMAPFONTATLAS_DEBUG_DRAW
#endif // CC_LABELBMFONT_DEBUG_DRAW
}

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
@ -55,6 +56,8 @@ bool CCLayer::init()
CCDirector * pDirector;
CC_BREAK_IF(!(pDirector = CCDirector::sharedDirector()));
this->setContentSize(pDirector->getWinSize());
m_bIsTouchEnabled = false;
m_bIsAccelerometerEnabled = false;
// success
bRet = true;
} while(0);
@ -375,7 +378,8 @@ bool CCLayerColor::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfl
for (unsigned int i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
{
m_pSquareVertices[i] = 0.0f;
m_pSquareVertices[i].x = 0.0f;
m_pSquareVertices[i].y = 0.0f;
}
this->updateColor();
@ -393,10 +397,10 @@ bool CCLayerColor::initWithColor(ccColor4B color)
/// override contentSize
void CCLayerColor::setContentSize(CCSize size)
{
m_pSquareVertices[2] = size.width * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[5] = size.height * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[6] = size.width * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[7] = size.height * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[1].x = size.width * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[2].y = size.height * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[3].x = size.width * CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[3].y = size.height * CC_CONTENT_SCALE_FACTOR();
CCLayer::setContentSize(size);
}
@ -420,10 +424,10 @@ void CCLayerColor::updateColor()
{
for( unsigned int i=0; i < 4; i++ )
{
m_pSquareColors[i * 4] = m_tColor.r;
m_pSquareColors[i * 4 + 1] = m_tColor.g;
m_pSquareColors[i * 4 + 2] = m_tColor.b;
m_pSquareColors[i * 4 + 3] = m_cOpacity;
m_pSquareColors[i].r = m_tColor.r;
m_pSquareColors[i].g = m_tColor.g;
m_pSquareColors[i].b = m_tColor.b;
m_pSquareColors[i].a = m_cOpacity;
}
}
@ -501,6 +505,8 @@ bool CCLayerGradient::initWithColor(ccColor4B start, ccColor4B end, CCPoint v)
m_AlongVector = v;
start.a = 255;
m_bCompressedInterpolation = true;
return CCLayerColor::initWithColor(start);
}
@ -508,13 +514,20 @@ void CCLayerGradient::updateColor()
{
CCLayerColor::updateColor();
float h = sqrtf(m_AlongVector.x * m_AlongVector.x + m_AlongVector.y * m_AlongVector.y);
float h = ccpLength(m_AlongVector);
if (h == 0)
return;
double c = sqrt(2.0);
CCPoint u = ccp(m_AlongVector.x / h, m_AlongVector.y / h);
// Compressed Interpolation mode
if (m_bCompressedInterpolation)
{
float h2 = 1 / ( fabsf(u.x) + fabsf(u.y) );
u = ccpMult(u, h2 * (float)c);
}
float opacityf = (float)m_cOpacity / 255.0f;
ccColor4B S = {
@ -532,25 +545,25 @@ void CCLayerGradient::updateColor()
};
// (-1, -1)
m_pSquareColors[0] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[1] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[2] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[3] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c)));
m_pSquareColors[0].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c)));
// (1, -1)
m_pSquareColors[4] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[5] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[6] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[7] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c)));
m_pSquareColors[1].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c)));
// (-1, 1)
m_pSquareColors[8] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[9] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[10] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[11] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c)));
m_pSquareColors[2].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c)));
// (1, 1)
m_pSquareColors[12] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[13] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[14] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[15] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c)));
m_pSquareColors[3].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)));
}
ccColor3B CCLayerGradient::getStartColor()
@ -607,24 +620,35 @@ CCPoint CCLayerGradient::getVector()
return m_AlongVector;
}
bool CCLayerGradient::getIsCompressedInterpolation()
{
return m_bCompressedInterpolation;
}
void CCLayerGradient::setIsCompressedInterpolation(bool compress)
{
m_bCompressedInterpolation = compress;
updateColor();
}
/// MultiplexLayer
CCMultiplexLayer::CCMultiplexLayer()
CCLayerMultiplex::CCLayerMultiplex()
: m_nEnabledLayer(0)
, m_pLayers(NULL)
{
}
CCMultiplexLayer::~CCMultiplexLayer()
CCLayerMultiplex::~CCLayerMultiplex()
{
CC_SAFE_RELEASE(m_pLayers);
}
CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)
CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...)
{
va_list args;
va_start(args,layer);
CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer();
CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex();
if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args))
{
pMultiplexLayer->autorelease();
@ -636,20 +660,20 @@ CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)
return NULL;
}
CCMultiplexLayer * CCMultiplexLayer::layerWithLayer(CCLayer* layer)
CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer)
{
CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer();
CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex();
pMultiplexLayer->initWithLayer(layer);
pMultiplexLayer->autorelease();
return pMultiplexLayer;
}
void CCMultiplexLayer::addLayer(CCLayer* layer)
void CCLayerMultiplex::addLayer(CCLayer* layer)
{
assert(m_pLayers);
m_pLayers->addObject(layer);
}
bool CCMultiplexLayer::initWithLayer(CCLayer* layer)
bool CCLayerMultiplex::initWithLayer(CCLayer* layer)
{
m_pLayers = new CCMutableArray<CCLayer*>(1);
m_pLayers->addObject(layer);
@ -658,7 +682,7 @@ bool CCMultiplexLayer::initWithLayer(CCLayer* layer)
return true;
}
bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params)
{
m_pLayers = new CCMutableArray<CCLayer*>(5);
//m_pLayers->retain();
@ -678,7 +702,7 @@ bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
}
void CCMultiplexLayer::switchTo(unsigned int n)
void CCLayerMultiplex::switchTo(unsigned int n)
{
CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
@ -689,7 +713,7 @@ void CCMultiplexLayer::switchTo(unsigned int n)
this->addChild(m_pLayers->getObjectAtIndex(n));
}
void CCMultiplexLayer::switchToAndReleaseMe(unsigned int n)
void CCLayerMultiplex::switchToAndReleaseMe(unsigned int n)
{
CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );

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

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
@ -164,6 +165,13 @@ namespace cocos2d{
pRet->autorelease();
return pRet;
}
CCMenuItemLabel* CCMenuItemLabel::itemWithLabel(CCNode *label)
{
CCMenuItemLabel *pRet = new CCMenuItemLabel();
pRet->initWithLabel(label, NULL, NULL);
pRet->autorelease();
return pRet;
}
bool CCMenuItemLabel::initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MenuHandler selector)
{
CCMenuItem::initWithTarget(target, selector);
@ -179,9 +187,7 @@ namespace cocos2d{
void CCMenuItemLabel::setString(const char * label)
{
m_pLabel->convertToLabelProtocol()->setString(label);
this->setContentSize(m_pLabel->getContentSize());
// [label_ setString:string];
// [self setContentSize: [label_ contentSize]];
this->setContentSize(m_pLabel->getContentSize());
}
void CCMenuItemLabel::activate()
{
@ -198,8 +204,17 @@ namespace cocos2d{
if(m_bIsEnabled)
{
CCMenuItem::selected();
this->stopActionByTag(kZoomActionTag);
m_fOriginalScale = this->getScale();
CCAction *action = getActionByTag(kZoomActionTag);
if (action)
{
this->stopAction(action);
}
else
{
m_fOriginalScale = this->getScale();
}
CCAction *zoomAction = CCScaleTo::actionWithDuration(0.1f, m_fOriginalScale * 1.2f);
zoomAction->setTag(kZoomActionTag);
this->runAction(zoomAction);

View File

@ -559,10 +559,6 @@
RelativePath="..\include\CCSpriteFrameCache.h"
>
</File>
<File
RelativePath="..\include\CCSpriteSheet.h"
>
</File>
<File
RelativePath="..\include\CCString.h"
>
@ -887,10 +883,6 @@
RelativePath="..\sprite_nodes\CCSpriteFrameCache.cpp"
>
</File>
<File
RelativePath="..\sprite_nodes\CCSpriteSheet.cpp"
>
</File>
</Filter>
<Filter
Name="support"

View File

@ -99,7 +99,6 @@ OBJECTS = \
$(OBJECTS_DIR)/CCSpriteBatchNode.o \
$(OBJECTS_DIR)/CCSpriteFrame.o \
$(OBJECTS_DIR)/CCSpriteFrameCache.o \
$(OBJECTS_DIR)/CCSpriteSheet.o \
$(OBJECTS_DIR)/base64.o \
$(OBJECTS_DIR)/CCArray.o \
$(OBJECTS_DIR)/CCPointExtension.o \
@ -344,9 +343,6 @@ $(OBJECTS_DIR)/CCSpriteFrame.o : ../sprite_nodes/CCSpriteFrame.cpp
$(OBJECTS_DIR)/CCSpriteFrameCache.o : ../sprite_nodes/CCSpriteFrameCache.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSpriteFrameCache.o ../sprite_nodes/CCSpriteFrameCache.cpp
$(OBJECTS_DIR)/CCSpriteSheet.o : ../sprite_nodes/CCSpriteSheet.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSpriteSheet.o ../sprite_nodes/CCSpriteSheet.cpp
$(OBJECTS_DIR)/base64.o : ../support/base64.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/base64.o ../support/base64.cpp

View File

@ -520,10 +520,6 @@
RelativePath="..\include\CCSpriteFrameCache.h"
>
</File>
<File
RelativePath="..\include\CCSpriteSheet.h"
>
</File>
<File
RelativePath="..\include\CCString.h"
>
@ -728,10 +724,6 @@
RelativePath="..\sprite_nodes\CCSpriteFrameCache.cpp"
>
</File>
<File
RelativePath="..\sprite_nodes\CCSpriteSheet.cpp"
>
</File>
</Filter>
<Filter
Name="support"

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) 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
@ -26,7 +27,6 @@ THE SOFTWARE.
#include "CCSpriteBatchNode.h"
#include "CCAnimation.h"
#include "CCAnimationCache.h"
#include "CCSpriteSheet.h"
#include "ccConfig.h"
#include "CCSprite.h"
#include "CCSpriteFrame.h"
@ -54,6 +54,7 @@ struct transformValues_ {
CCPoint pos; // position x and y
CCPoint scale; // scale x and y
float rotation;
CCPoint skew; // skew x and y
CCPoint ap; // anchor point in pixels
bool visible;
};
@ -167,17 +168,12 @@ CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName)
return spriteWithSpriteFrame(pFrame);
}
CCSprite* CCSprite::spriteWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect)
{
return spriteWithBatchNode(pSpriteSheet, rect);
}
bool CCSprite::init(void)
{
m_bDirty = m_bRecursiveDirty = false;
// by default use "Self Render".
// if the sprite is added to an SpriteSheet, then it will automatically switch to "SpriteSheet Render"
// if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render"
useSelfRender();
m_bOpacityModifyRGB = true;
@ -323,11 +319,6 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
}
*/
bool CCSprite::initWithSpriteSheet(CCSpriteSheetInternalOnly *pSpriteSheet, CCRect rect)
{
return initWithBatchNode(pSpriteSheet, rect);
}
CCSprite::CCSprite()
: m_pobTexture(NULL)
{
@ -365,11 +356,6 @@ void CCSprite::useBatchNode(CCSpriteBatchNode *batchNode)
m_pobBatchNode = batchNode;
}
void CCSprite::useSpriteSheetRender(CCSpriteSheetInternalOnly *pSpriteSheet)
{
useBatchNode(pSpriteSheet);
}
void CCSprite::initAnimationDictionary(void)
{
m_pAnimations = new CCMutableDictionary<string, CCAnimation*>();
@ -406,7 +392,7 @@ void CCSprite::setTextureRectInPixels(CCRect rect, bool rotated, CCSize size)
m_obOffsetPositionInPixels.x = relativeOffsetInPixels.x + (m_tContentSizeInPixels.width - m_obRectInPixels.size.width) / 2;
m_obOffsetPositionInPixels.y = relativeOffsetInPixels.y + (m_tContentSizeInPixels.height - m_obRectInPixels.size.height) / 2;
// rendering using SpriteSheet
// rendering using batch node
if (m_bUsesBatchNode)
{
// update dirty_, don't update recursiveDirty_
@ -544,6 +530,13 @@ void CCSprite::updateTransform(void)
matrix = CCAffineTransformMake(c * m_fScaleX, s * m_fScaleX,
-s * m_fScaleY, c * m_fScaleY,
m_tPositionInPixels.x, m_tPositionInPixels.y);
if( m_fSkewX || m_fSkewY )
{
CCAffineTransform skewMatrix = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)),
tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f,
0.0f, 0.0f);
matrix = CCAffineTransformConcat(skewMatrix, matrix);
}
matrix = CCAffineTransformTranslate(matrix, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);
} else // parent_ != batchNode_
{
@ -571,7 +564,7 @@ void CCSprite::updateTransform(void)
CCAffineTransform newMatrix = CCAffineTransformIdentity;
// 2nd: Translate, Rotate, Scale
// 2nd: Translate, Skew, Rotate, Scale
if( prevHonor & CC_HONOR_PARENT_TRANSFORM_TRANSLATE )
{
newMatrix = CCAffineTransformTranslate(newMatrix, tv.pos.x, tv.pos.y);
@ -582,6 +575,13 @@ void CCSprite::updateTransform(void)
newMatrix = CCAffineTransformRotate(newMatrix, -CC_DEGREES_TO_RADIANS(tv.rotation));
}
if ( prevHonor & CC_HONOR_PARENT_TRANSFORM_SKEW )
{
CCAffineTransform skew = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(tv.skew.y)), tanf(CC_DEGREES_TO_RADIANS(tv.skew.x)), 1.0f, 0.0f, 0.0f);
// apply the skew to the transform
newMatrix = CCAffineTransformConcat(skew, newMatrix);
}
if( prevHonor & CC_HONOR_PARENT_TRANSFORM_SCALE )
{
newMatrix = CCAffineTransformScale(newMatrix, tv.scale.x, tv.scale.y);
@ -643,6 +643,8 @@ void CCSprite::getTransformValues(struct transformValues_ *tv)
tv->scale.x = m_fScaleX;
tv->scale.y = m_fScaleY;
tv->rotation = m_fRotation;
tv->skew.x = m_fSkewX;
tv->skew.y = m_fSkewY;
tv->ap = m_tAnchorPointInPixels;
tv->visible = m_bIsVisible;
}
@ -835,6 +837,18 @@ void CCSprite::setRotation(float fRotation)
SET_DIRTY_RECURSIVELY();
}
void CCSprite::setSkewX(float sx)
{
CCNode::setSkewX(sx);
SET_DIRTY_RECURSIVELY();
}
void CCSprite::setSkewY(float sy)
{
CCNode::setSkewY(sy);
SET_DIRTY_RECURSIVELY();
}
void CCSprite::setScaleX(float fScaleX)
{
CCNode::setScaleX(fScaleX);
@ -882,7 +896,7 @@ void CCSprite::setFlipX(bool bFlipX)
if (m_bFlipX != bFlipX)
{
m_bFlipX = bFlipX;
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_obRectInPixels.size);
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_tContentSizeInPixels);
}
}
@ -896,7 +910,7 @@ void CCSprite::setFlipY(bool bFlipY)
if (m_bFlipY != bFlipY)
{
m_bFlipY = bFlipY;
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_obRectInPixels.size);
setTextureRectInPixels(m_obRectInPixels, m_bRectRotated, m_tContentSizeInPixels);
}
}
@ -1050,7 +1064,11 @@ bool CCSprite::isFrameDisplayed(CCSpriteFrame *pFrame)
CCSpriteFrame* CCSprite::displayedFrame(void)
{
return CCSpriteFrame::frameWithTexture(m_pobTexture, m_obRect);
return CCSpriteFrame::frameWithTexture(m_pobTexture,
m_obRectInPixels,
m_bRectRotated,
m_obUnflippedOffsetPositionFromCenter,
m_tContentSizeInPixels);
}
void CCSprite::addAnimation(CCAnimation *pAnimation)

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2009 Matt Oswald
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -335,8 +336,9 @@ namespace cocos2d
// this is likely computationally expensive
unsigned int quantity = (m_pobTextureAtlas->getCapacity() + 1) * 4 / 3;
CCLOG("cocos2d: CCSpriteSheet: resizing TextureAtlas capacity from %u to %u.",
(unsigned int)m_pobTextureAtlas->getCapacity(), (unsigned int)quantity);
CCLOG("cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
(long)m_pobTextureAtlas->getCapacity(),
(long)quantity);
if (! m_pobTextureAtlas->resizeCapacity(quantity))
{

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
@ -86,4 +87,17 @@ CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
return pCopy;
}
void CCSpriteFrame::setRect(CCRect rect)
{
m_obRect = rect;
m_obRectInPixels = CC_RECT_POINTS_TO_PIXELS(m_obRect);
}
void CCSpriteFrame::setRectInPixels(CCRect rectInPixels)
{
m_obRectInPixels = rectInPixels;
m_obRect = CC_RECT_PIXELS_TO_POINTS(rectInPixels);
}
}//namespace cocos2d

View File

@ -3,6 +3,7 @@ Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2009 Jason Booth
Copyright (c) 2009 Robert J Payne
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -233,22 +234,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
if (! texturePath.empty())
{
// build texture path relative to plist file
// stringByDeletingLastPathComponent
string textureBase(pszPath);
int indexOfLastSeperator = textureBase.find_last_of('/');
if (indexOfLastSeperator == (int)textureBase.length() - 1)
{
textureBase.erase(indexOfLastSeperator, 1);
indexOfLastSeperator = textureBase.find_last_of('/');
}
textureBase.erase(indexOfLastSeperator);
// stringByAppendingPathComponent
if (! textureBase.empty())
{
texturePath = textureBase + "/" + texturePath;
}
texturePath = CCFileUtils::fullPathFromRelativeFile(texturePath.c_str(), pszPath);
}
else
{

View File

@ -1,31 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2009 Matt Oswald
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCSpriteSheet.h"
namespace cocos2d {
}//namespace cocos2d

View File

@ -34,14 +34,13 @@ namespace cocos2d
// Should buffer factor be 1.5 instead of 2 ?
#define BUFFER_INC_FACTOR (2)
int ZipUtils::inflateMemory_(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength)
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength, unsigned int outLenghtHint)
{
/* ret value */
int err = Z_OK;
/* 256k initial decompress buffer */
int bufferSize = 256 * 1024;
*out = new unsigned char[bufferSize];
int bufferSize = outLenghtHint;
*out = (unsigned char*) malloc(bufferSize);
z_stream d_stream; /* decompression stream */
d_stream.zalloc = (alloc_func)0;
@ -55,11 +54,10 @@ namespace cocos2d
/* window size to hold 256k */
if( (err = inflateInit2(&d_stream, 15 + 32)) != Z_OK )
{
return err;
}
for (;;) {
for (;;)
{
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END)
@ -67,28 +65,30 @@ namespace cocos2d
break;
}
switch (err) {
switch (err)
{
case Z_NEED_DICT:
err = Z_DATA_ERROR;
case Z_DATA_ERROR:
case Z_MEM_ERROR:
inflateEnd(&d_stream);
return err;
}
}
// not enough memory ?
if (err != Z_STREAM_END)
{
delete [] *out;
*out = new unsigned char[bufferSize * BUFFER_INC_FACTOR];
unsigned char *tmp = (unsigned char*)realloc(*out, bufferSize * BUFFER_INC_FACTOR);
/* not enough memory, ouch */
if (! *out )
if (! tmp )
{
CCLOG("cocos2d: ZipUtils: realloc failed");
inflateEnd(&d_stream);
return Z_MEM_ERROR;
}
/* only assign to *out if tmp is valid. it's not guaranteed that realloc will reuse the memory */
*out = tmp;
d_stream.next_out = *out + bufferSize;
d_stream.avail_out = bufferSize;
@ -96,16 +96,15 @@ namespace cocos2d
}
}
*outLength = bufferSize - d_stream.avail_out;
err = inflateEnd(&d_stream);
return err;
}
int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out)
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint)
{
unsigned int outLength = 0;
int err = inflateMemory_(in, inLength, out, &outLength);
int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint);
if (err != Z_OK || *out == NULL) {
if (err == Z_MEM_ERROR)
@ -133,6 +132,12 @@ namespace cocos2d
return outLength;
}
int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out)
{
// 256k for hint
return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024);
}
int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out)
{
int len;

View File

@ -51,12 +51,25 @@ namespace cocos2d
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*
* It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
* @returns the length of the deflated buffer
*
@since v0.8.1
*/
static int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
/**
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*
* outLenghtHint is assumed to be the needed room to allocate the inflated buffer.
*
* @returns the length of the deflated buffer
*
@since v1.0.0
*/
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint);
/** inflates a GZip file into memory
*
* @returns the length of the deflated buffer
@ -74,7 +87,8 @@ namespace cocos2d
static int ccInflateCCZFile(const char *filename, unsigned char **out);
private:
static int inflateMemory_(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLengh);
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength,
unsigned int outLenghtHint);
};
} // end of namespace cocos2d

View File

@ -405,5 +405,10 @@ void CCTextureAtlas::drawNumberOfQuads(unsigned int n)
#endif // CC_USES_VBO
}
void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
{
}
}//namespace cocos2d

View File

@ -431,7 +431,8 @@ void CCTextureCache::removeTextureForKey(const char *textureKeyName)
return;
}
m_pTextures->removeObjectForKey(string(textureKeyName));
string fullPath = CCFileUtils::fullPathFromRelativePath(textureKeyName);
m_pTextures->removeObjectForKey(fullPath);
}
CCTexture2D* CCTextureCache::textureForKey(const char* key)

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -69,14 +70,14 @@ namespace cocos2d {
pRet->autorelease();
return pRet;
}
void CCParallaxNode::addChild(CCNode * child, int zOrder, int tag)
void CCParallaxNode::addChild(CCNode * child, unsigned int zOrder, int tag)
{
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(tag);
CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
}
void CCParallaxNode::addChild(CCNode *child, int z, CCPoint ratio, CCPoint offset)
void CCParallaxNode::addChild(CCNode *child, unsigned int z, CCPoint ratio, CCPoint offset)
{
CCAssert( child != NULL, "Argument must be non-nil");
CCPointObject *obj = CCPointObject::pointWithCCPoint(ratio, offset);

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -74,7 +75,7 @@ namespace cocos2d {
// mapInfo
m_tMapTileSize = mapInfo->getTileSize();
m_nLayerOrientation = mapInfo->getOrientation();
m_uLayerOrientation = mapInfo->getOrientation();
// offset (after layer orientation is set);
CCPoint offset = this->calculateLayerOffset(layerInfo->m_tOffset);
@ -236,7 +237,7 @@ namespace cocos2d {
{
CCRect rect = m_pTileSet->rectForGID(gid);
tile = new CCSprite();
tile->initWithSpriteSheet((CCSpriteSheetInternalOnly *)this, rect);
tile->initWithBatchNode(this, rect);
tile->setPositionInPixels(positionAt(pos));
tile->setVertexZ((float)vertexZForPos(pos));
tile->setAnchorPoint(CCPointZero);
@ -268,11 +269,11 @@ namespace cocos2d {
if( ! m_pReusedTile )
{
m_pReusedTile = new CCSprite();
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
else
{
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
m_pReusedTile->setPositionInPixels(positionAt(pos));
m_pReusedTile->setVertexZ((float)vertexZForPos(pos));
@ -316,11 +317,11 @@ namespace cocos2d {
if( ! m_pReusedTile )
{
m_pReusedTile = new CCSprite();
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
else
{
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
m_pReusedTile->setPositionInPixels(positionAt(pos));
@ -349,11 +350,11 @@ namespace cocos2d {
if( ! m_pReusedTile )
{
m_pReusedTile = new CCSprite();
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
else
{
m_pReusedTile->initWithSpriteSheet((CCSpriteSheetInternalOnly *) this, rect);
m_pReusedTile->initWithBatchNode(this, rect);
}
m_pReusedTile->setPosition(positionAt(pos));
@ -519,7 +520,7 @@ namespace cocos2d {
CCPoint CCTMXLayer::calculateLayerOffset(CCPoint pos)
{
CCPoint ret = CCPointZero;
switch( m_nLayerOrientation )
switch( m_uLayerOrientation )
{
case CCTMXOrientationOrtho:
ret = ccp( pos.x * m_tMapTileSize.width, -pos.y *m_tMapTileSize.height);
@ -537,7 +538,7 @@ namespace cocos2d {
CCPoint CCTMXLayer::positionAt(CCPoint pos)
{
CCPoint ret = CCPointZero;
switch( m_nLayerOrientation )
switch( m_uLayerOrientation )
{
case CCTMXOrientationOrtho:
ret = positionForOrthoAt(pos);
@ -581,7 +582,7 @@ namespace cocos2d {
unsigned int maxVal = 0;
if( m_bUseAutomaticVertexZ )
{
switch( m_nLayerOrientation )
switch( m_uLayerOrientation )
{
case CCTMXOrientationIso:
maxVal = (unsigned int)(m_tLayerSize.width + m_tLayerSize.height);

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
Copyright (c) 2010 Neophit
Copyright (c) 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) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -154,9 +155,6 @@ namespace cocos2d{
CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo)
{
CCTMXTilesetInfo *tileset = NULL;
//CFByteOrder o = CFByteOrderGetCurrent();
CCSize size = layerInfo->m_tLayerSize;
CCMutableArray<CCTMXTilesetInfo*>* tilesets = mapInfo->getTilesets();
if (tilesets && tilesets->count()>0)
@ -197,7 +195,7 @@ namespace cocos2d{
// If all the tiles are 0, return empty tileset
CCLOG("cocos2d: Warning: TMX Layer '%@' has no tiles", layerInfo->m_sName.c_str());
return tileset;
return NULL;
}

View File

@ -2,6 +2,7 @@
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2009-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
@ -391,10 +392,15 @@ namespace cocos2d {
{
layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribGzip);
} else
if (compression == "zip")
{
layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribZlib);
}
CCAssert( compression == "" || compression == "gzip", "TMX: unsupported compression method" );
CCAssert( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" );
}
CCAssert( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip maps are supported" );
CCAssert( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported" );
}
else if(elementName == "object")
@ -534,17 +540,25 @@ namespace cocos2d {
std::string currentString = pTMXMapInfo->getCurrentString();
unsigned char *buffer;
len = base64Decode((unsigned char*)currentString.c_str(), currentString.length(), &buffer);
len = base64Decode((unsigned char*)currentString.c_str(), (unsigned int)currentString.length(), &buffer);
if( ! buffer )
{
CCLOG("cocos2d: TiledMap: decode data error");
return;
}
if( pTMXMapInfo->getLayerAttribs() & TMXLayerAttribGzip )
if( pTMXMapInfo->getLayerAttribs() & (TMXLayerAttribGzip | TMXLayerAttribZlib) )
{
unsigned char *deflated;
ZipUtils::ccInflateMemory(buffer, len, &deflated);
CCSize s = layer->m_tLayerSize;
// int sizeHint = s.width * s.height * sizeof(uint32_t);
int sizeHint = (int)(s.width * s.height * sizeof(unsigned int));
int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint);
assert(inflatedLen == sizeHint);
inflatedLen = (int)&inflatedLen; // XXX: to avoid warings in compiler
delete [] buffer;
buffer = NULL;

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
@ -52,8 +53,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;
@ -174,28 +175,28 @@ namespace cocos2d {
return value;
}
void CCTileMapAtlas::updateAtlasValueAt(ccGridSize pos, ccColor3B value, int index)
void CCTileMapAtlas::updateAtlasValueAt(ccGridSize pos, ccColor3B value, unsigned int index)
{
ccV3F_C4B_T2F_Quad quad;
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 +208,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);

View File

@ -1 +1 @@
38bc28fc563959965a8c07d2e075ee119d679548
f9eeef82ddc1e3dda52514fcd2d7c424f60c1cd8

View File

@ -95,6 +95,17 @@ public class Cocos2dxSound {
return INVALID_SOUND_ID;
}
/*
* Someone reports that, it can not play effect for the
* first time. If you are lucky to meet it. There are two
* ways to resolve it.
* 1. Add some delay here. I don't know how long it is, so
* I don't add it here.
* 2. If you use 2.2(API level 8), you can call
* SoundPool.setOnLoadCompleteListener() to play the effect.
* Because the method is supported from 2.2, so I can't use
* it here.
*/
playEffect(path);
}

View File

@ -1 +1 @@
7e980559929775d4de226f44727a9e3ff4d273fc
e7091c4916f64410b2c21e12c9943931c427ecdf

View File

@ -112,12 +112,12 @@ MenuLayer1::~MenuLayer1()
void MenuLayer1::menuCallback(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(1);
((CCLayerMultiplex*)m_pParent)->switchTo(1);
}
void MenuLayer1::menuCallbackConfig(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(3);
((CCLayerMultiplex*)m_pParent)->switchTo(3);
}
void MenuLayer1::menuCallbackDisabled(CCObject* sender)
@ -131,7 +131,7 @@ void MenuLayer1::menuCallbackEnable(CCObject* sender)
void MenuLayer1::menuCallback2(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(2);
((CCLayerMultiplex*)m_pParent)->switchTo(2);
}
void MenuLayer1::onQuit(CCObject* sender)
@ -223,7 +223,7 @@ void MenuLayer2::alignMenusV()
void MenuLayer2::menuCallback(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(0);
((CCLayerMultiplex*)m_pParent)->switchTo(0);
}
void MenuLayer2::menuCallbackOpacity(CCObject* sender)
@ -301,7 +301,7 @@ MenuLayer3::~MenuLayer3()
void MenuLayer3::menuCallback(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(0);
((CCLayerMultiplex*)m_pParent)->switchTo(0);
}
void MenuLayer3::menuCallback2(CCObject* sender)
@ -412,7 +412,7 @@ void MenuLayer4::menuCallback(CCObject* sender)
void MenuLayer4::backCallback(CCObject* sender)
{
((CCMultiplexLayer*)m_pParent)->switchTo(0);
((CCLayerMultiplex*)m_pParent)->switchTo(0);
}
void MenuTestScene::runThisTest()
@ -422,7 +422,7 @@ void MenuTestScene::runThisTest()
CCLayer* pLayer3 = new MenuLayer3();
CCLayer* pLayer4 = new MenuLayer4();
CCMultiplexLayer* layer = CCMultiplexLayer::layerWithLayers(pLayer1, pLayer2, pLayer3, pLayer4, NULL);
CCLayerMultiplex* layer = CCLayerMultiplex::layerWithLayers(pLayer1, pLayer2, pLayer3, pLayer4, NULL);
addChild(layer, 0);
pLayer1->release();