mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20' of https://github.com/cocos2d/cocos2d-x into android_gles20
This commit is contained in:
commit
7ccb38556e
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#include "cocoa/CCNS.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCScene.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCScheduler.h"
|
||||
#include "ccMacros.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
|
@ -96,7 +96,8 @@ bool CCDirector::init(void)
|
|||
m_pNotificationNode = NULL;
|
||||
|
||||
m_dOldAnimationInterval = m_dAnimationInterval = 1.0 / kDefaultFPS;
|
||||
m_pobScenesStack = new CCMutableArray<CCScene*>();
|
||||
m_pobScenesStack = CCArray::array();
|
||||
m_pobScenesStack->retain();
|
||||
|
||||
// Set default projection (3D)
|
||||
m_eProjection = kCCDirectorProjectionDefault;
|
||||
|
@ -336,8 +337,9 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
|
|||
{
|
||||
// reset the viewport if 3d proj & retina display
|
||||
if( CC_CONTENT_SCALE_FACTOR() != 1 )
|
||||
{
|
||||
glViewport(-size.width/2, -size.height/2, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() );
|
||||
|
||||
}
|
||||
float zeye = this->getZEye();
|
||||
|
||||
kmMat4 matrixPerspective, matrixLookup;
|
||||
|
@ -563,7 +565,7 @@ void CCDirector::popScene(void)
|
|||
else
|
||||
{
|
||||
m_bSendCleanupToScene = true;
|
||||
m_pNextScene = m_pobScenesStack->getObjectAtIndex(c - 1);
|
||||
m_pNextScene = (CCScene*)m_pobScenesStack->objectAtIndex(c - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget
|
|||
pElement->currentTimerSalvaged = true;
|
||||
}
|
||||
|
||||
ccArrayRemoveObjectAtIndex(pElement->timers, i );
|
||||
ccArrayRemoveObjectAtIndex(pElement->timers, i, true);
|
||||
|
||||
// update timerIndex in case we are in tick:, looping over the actions
|
||||
if (pElement->timerIndex >= i)
|
||||
|
|
|
@ -2055,10 +2055,13 @@ bool CCAnimate::initWithAnimation(CCAnimation *pAnimation)
|
|||
float accumUnitsOfTime = 0;
|
||||
float newUnitOfTimeValue = singleDuration / pAnimation->getTotalDelayUnits();
|
||||
|
||||
CCMutableArray<CCAnimationFrame*>* pFrames = pAnimation->getFrames();
|
||||
for (CCMutableArray<CCAnimationFrame*>::CCMutableArrayIterator iterFrame = pFrames->begin(); iterFrame != pFrames->end(); ++iterFrame)
|
||||
CCArray* pFrames = pAnimation->getFrames();
|
||||
CCARRAY_VERIFY_TYPE(pFrames, CCAnimationFrame*);
|
||||
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(pFrames, pObj)
|
||||
{
|
||||
CCAnimationFrame *frame = *iterFrame;
|
||||
CCAnimationFrame* frame = (CCAnimationFrame*)pObj;
|
||||
float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
|
||||
accumUnitsOfTime += frame->getDelayUnits();
|
||||
m_pSplitTimes->push_back(value);
|
||||
|
@ -2151,7 +2154,7 @@ void CCAnimate::update(ccTime t)
|
|||
t = fmodf(t, 1.0f);
|
||||
}
|
||||
|
||||
CCMutableArray<CCAnimationFrame*>* frames = m_pAnimation->getFrames();
|
||||
CCArray* frames = m_pAnimation->getFrames();
|
||||
unsigned int numberOfFrames = frames->count();
|
||||
CCSpriteFrame *frameToDisplay = NULL;
|
||||
|
||||
|
@ -2159,11 +2162,11 @@ void CCAnimate::update(ccTime t)
|
|||
float splitTime = m_pSplitTimes->at(i);
|
||||
|
||||
if( splitTime <= t ) {
|
||||
CCAnimationFrame *frame = frames->getObjectAtIndex(i);
|
||||
CCAnimationFrame* frame = (CCAnimationFrame*)frames->objectAtIndex(i);
|
||||
frameToDisplay = frame->getSpriteFrame();
|
||||
((CCSprite*)m_pTarget)->setDisplayFrame(frameToDisplay);
|
||||
|
||||
CCObjectDictionary* dict = frame->getUserInfo();
|
||||
CCDictionary* dict = frame->getUserInfo();
|
||||
if( dict )
|
||||
{
|
||||
//TODO: [[NSNotificationCenter defaultCenter] postNotificationName:CCAnimationFrameDisplayedNotification object:target_ userInfo:dict];
|
||||
|
@ -2177,16 +2180,17 @@ void CCAnimate::update(ccTime t)
|
|||
|
||||
CCActionInterval* CCAnimate::reverse(void)
|
||||
{
|
||||
CCMutableArray<CCAnimationFrame*>* pOldArray = m_pAnimation->getFrames();
|
||||
CCMutableArray<CCAnimationFrame*>* pNewArray = new CCMutableArray<CCAnimationFrame*>(pOldArray->count());
|
||||
CCArray* pOldArray = m_pAnimation->getFrames();
|
||||
CCArray* pNewArray = CCArray::arrayWithCapacity(pOldArray->count());
|
||||
|
||||
CCARRAY_VERIFY_TYPE(pOldArray, CCAnimationFrame*);
|
||||
|
||||
if (pOldArray->count() > 0)
|
||||
{
|
||||
CCAnimationFrame *pElement;
|
||||
CCMutableArray<CCAnimationFrame*>::CCMutableArrayRevIterator iter;
|
||||
for (iter = pOldArray->rbegin(); iter != pOldArray->rend(); iter++)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH_REVERSE(pOldArray, pObj)
|
||||
{
|
||||
pElement = *iter;
|
||||
CCAnimationFrame* pElement = (CCAnimationFrame*)pObj;
|
||||
if (! pElement)
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -95,7 +95,7 @@ void CCActionManager::removeActionAtIndex(unsigned int uIndex, tHashElement *pEl
|
|||
pElement->currentActionSalvaged = true;
|
||||
}
|
||||
|
||||
ccArrayRemoveObjectAtIndex(pElement->actions, uIndex);
|
||||
ccArrayRemoveObjectAtIndex(pElement->actions, uIndex, true);
|
||||
|
||||
// update actionIndex in case we are in tick. looping over the actions
|
||||
if (pElement->actionIndex >= uIndex)
|
||||
|
|
|
@ -24,14 +24,14 @@ THE SOFTWARE.
|
|||
#include "CCAutoreleasePool.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
NS_CC_BEGIN
|
||||
|
||||
CCPoolManager g_PoolManager;
|
||||
|
||||
CCAutoreleasePool::CCAutoreleasePool(void)
|
||||
{
|
||||
m_pManagedObjectArray = new CCMutableArray<CCObject*>();
|
||||
m_pManagedObjectArray = new CCArray();
|
||||
m_pManagedObjectArray->init();
|
||||
}
|
||||
|
||||
CCAutoreleasePool::~CCAutoreleasePool(void)
|
||||
|
@ -61,13 +61,14 @@ void CCAutoreleasePool::clear()
|
|||
#ifdef _DEBUG
|
||||
int nIndex = m_pManagedObjectArray->count() - 1;
|
||||
#endif
|
||||
CCMutableArray<CCObject*>::CCMutableArrayRevIterator it;
|
||||
for(it = m_pManagedObjectArray->rbegin(); it != m_pManagedObjectArray->rend(); ++it)
|
||||
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH_REVERSE(m_pManagedObjectArray, pObj)
|
||||
{
|
||||
if(!*it)
|
||||
if(!pObj)
|
||||
break;
|
||||
|
||||
(*it)->m_bManaged = false;
|
||||
pObj->m_bManaged = false;
|
||||
//(*it)->release();
|
||||
//delete (*it);
|
||||
#ifdef _DEBUG
|
||||
|
@ -93,8 +94,9 @@ CCPoolManager* CCPoolManager::getInstance()
|
|||
|
||||
CCPoolManager::CCPoolManager()
|
||||
{
|
||||
m_pReleasePoolStack = new CCMutableArray<CCAutoreleasePool*>();
|
||||
m_pCurReleasePool = 0;
|
||||
m_pReleasePoolStack = new CCArray();
|
||||
m_pReleasePoolStack->init();
|
||||
m_pCurReleasePool = 0;
|
||||
}
|
||||
|
||||
CCPoolManager::~CCPoolManager()
|
||||
|
@ -103,7 +105,7 @@ CCPoolManager::~CCPoolManager()
|
|||
finalize();
|
||||
|
||||
// we only release the last autorelease pool here
|
||||
m_pCurReleasePool = 0;
|
||||
m_pCurReleasePool = 0;
|
||||
m_pReleasePoolStack->removeObjectAtIndex(0);
|
||||
|
||||
CC_SAFE_DELETE(m_pReleasePoolStack);
|
||||
|
@ -114,13 +116,13 @@ void CCPoolManager::finalize()
|
|||
if(m_pReleasePoolStack->count() > 0)
|
||||
{
|
||||
//CCAutoreleasePool* pReleasePool;
|
||||
CCMutableArray<CCAutoreleasePool*>::CCMutableArrayIterator it;
|
||||
for(it = m_pReleasePoolStack->begin(); it != m_pReleasePoolStack->end(); ++it)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pReleasePoolStack, pObj)
|
||||
{
|
||||
if(!*it)
|
||||
if(!pObj)
|
||||
break;
|
||||
|
||||
(*it)->clear();
|
||||
CCAutoreleasePool* pPool = (CCAutoreleasePool*)pObj;
|
||||
pPool->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,10 +154,10 @@ void CCPoolManager::pop()
|
|||
|
||||
// if(nCount > 1)
|
||||
// {
|
||||
// m_pCurReleasePool = m_pReleasePoolStack->getObjectAtIndex(nCount - 2);
|
||||
// m_pCurReleasePool = m_pReleasePoolStack->objectAtIndex(nCount - 2);
|
||||
// return;
|
||||
// }
|
||||
m_pCurReleasePool = m_pReleasePoolStack->getObjectAtIndex(nCount - 2);
|
||||
m_pCurReleasePool = (CCAutoreleasePool*)m_pReleasePoolStack->objectAtIndex(nCount - 2);
|
||||
}
|
||||
|
||||
/*m_pCurReleasePool = NULL;*/
|
||||
|
@ -186,4 +188,4 @@ CCAutoreleasePool* CCPoolManager::getCurReleasePool()
|
|||
return m_pCurReleasePool;
|
||||
}
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
#include "CCDictionary.h"
|
||||
#include "CCString.h"
|
||||
#include "CCInteger.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
CCDictionary::CCDictionary()
|
||||
: m_pElements(NULL)
|
||||
, m_eDictType(kCCDictUnknown)
|
||||
, m_eOldDictType(kCCDictUnknown)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCDictionary::~CCDictionary()
|
||||
{
|
||||
removeAllObjects();
|
||||
}
|
||||
|
||||
unsigned int CCDictionary::count()
|
||||
{
|
||||
return HASH_COUNT(m_pElements);
|
||||
}
|
||||
|
||||
CCArray* CCDictionary::allKeys()
|
||||
{
|
||||
int iKeyCount = this->count();
|
||||
if (iKeyCount <= 0) return NULL;
|
||||
CCArray* pArray = CCArray::arrayWithCapacity(iKeyCount);
|
||||
|
||||
CCDictElement *pElement, *tmp;
|
||||
if (m_eDictType == kCCDictStr)
|
||||
{
|
||||
HASH_ITER(hh, m_pElements, pElement, tmp)
|
||||
{
|
||||
CCString* pOneKey = new CCString(pElement->m_szKey);
|
||||
pOneKey->autorelease();
|
||||
pArray->addObject(pOneKey);
|
||||
}
|
||||
}
|
||||
else if (m_eDictType == kCCDictInt)
|
||||
{
|
||||
HASH_ITER(hh, m_pElements, pElement, tmp)
|
||||
{
|
||||
CCInteger* pOneKey = new CCInteger(pElement->m_iKey);
|
||||
pOneKey->autorelease();
|
||||
pArray->addObject(pOneKey);
|
||||
}
|
||||
}
|
||||
|
||||
return pArray;
|
||||
}
|
||||
|
||||
CCArray* CCDictionary::allKeysForObject(CCObject* object)
|
||||
{
|
||||
int iKeyCount = this->count();
|
||||
if (iKeyCount <= 0) return NULL;
|
||||
CCArray* pArray = CCArray::array();
|
||||
|
||||
CCDictElement *pElement, *tmp;
|
||||
|
||||
if (m_eDictType == kCCDictStr)
|
||||
{
|
||||
HASH_ITER(hh, m_pElements, pElement, tmp)
|
||||
{
|
||||
if (object == pElement->m_pObject)
|
||||
{
|
||||
CCString* pOneKey = new CCString(pElement->m_szKey);
|
||||
pOneKey->autorelease();
|
||||
pArray->addObject(pOneKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_eDictType == kCCDictInt)
|
||||
{
|
||||
HASH_ITER(hh, m_pElements, pElement, tmp)
|
||||
{
|
||||
if (object == pElement->m_pObject)
|
||||
{
|
||||
CCInteger* pOneKey = new CCInteger(pElement->m_iKey);
|
||||
pOneKey->autorelease();
|
||||
pArray->addObject(pOneKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pArray;
|
||||
}
|
||||
|
||||
CCObject* CCDictionary::objectForKey(const char* key)
|
||||
{
|
||||
if (m_eDictType == kCCDictUnknown && m_eDictType == kCCDictUnknown) return NULL;
|
||||
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
|
||||
|
||||
CCObject* pRetObject = NULL;
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_STR(m_pElements,key, pElement);
|
||||
if (pElement != NULL)
|
||||
{
|
||||
pRetObject = pElement->m_pObject;
|
||||
}
|
||||
return pRetObject;
|
||||
}
|
||||
|
||||
CCObject* CCDictionary::objectForKey(int key)
|
||||
{
|
||||
if (m_eDictType == kCCDictUnknown && m_eDictType == kCCDictUnknown) return NULL;
|
||||
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
|
||||
|
||||
CCObject* pRetObject = NULL;
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_INT(m_pElements, &key, pElement);
|
||||
if (pElement != NULL)
|
||||
{
|
||||
pRetObject = pElement->m_pObject;
|
||||
}
|
||||
return pRetObject;
|
||||
}
|
||||
|
||||
bool CCDictionary::setObject(CCObject* pObject, const char* key)
|
||||
{
|
||||
CCAssert(key != NULL && strlen(key) > 0 && pObject != NULL, "Invalid Argument!");
|
||||
if (m_eOldDictType == kCCDictUnknown)
|
||||
{
|
||||
m_eOldDictType = kCCDictStr;
|
||||
}
|
||||
m_eDictType = kCCDictStr;
|
||||
CCAssert(m_eDictType == m_eOldDictType, "this dictionary does not use string as key.");
|
||||
|
||||
bool bRet = false;
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_STR(m_pElements, key, pElement);
|
||||
if (pElement == NULL)
|
||||
{
|
||||
pObject->retain();
|
||||
pElement = new CCDictElement(key, pObject);
|
||||
HASH_ADD_STR(m_pElements, m_szKey, pElement);
|
||||
bRet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCObject* pTmpObj = pElement->m_pObject;
|
||||
pTmpObj->retain();
|
||||
removeObjectForKey(key);
|
||||
setObject(pObject, key);
|
||||
pTmpObj->release();
|
||||
bRet = true;
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool CCDictionary::setObject(CCObject* pObject, int key)
|
||||
{
|
||||
CCAssert(pObject != NULL, "Invalid Argument!");
|
||||
if (m_eOldDictType == kCCDictUnknown)
|
||||
{
|
||||
m_eOldDictType = kCCDictInt;
|
||||
}
|
||||
m_eDictType = kCCDictInt;
|
||||
CCAssert(m_eDictType == m_eOldDictType, "this dictionary does not use integer as key.");
|
||||
|
||||
bool bRet = false;
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_INT(m_pElements, &key, pElement);
|
||||
if (pElement == NULL)
|
||||
{
|
||||
pObject->retain();
|
||||
pElement = new CCDictElement(key, pObject);
|
||||
HASH_ADD_INT(m_pElements, m_iKey, pElement);
|
||||
bRet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCObject* pTmpObj = pElement->m_pObject;
|
||||
pTmpObj->retain();
|
||||
removeObjectForKey(key);
|
||||
setObject(pObject, key);
|
||||
pTmpObj->release();
|
||||
bRet = true;
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void CCDictionary::removeObjectForKey(const char* key)
|
||||
{
|
||||
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as its key");
|
||||
CCAssert(key != NULL && strlen(key) > 0, "Invalid Argument!");
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_STR(m_pElements, key, pElement);
|
||||
if (pElement)
|
||||
{
|
||||
HASH_DEL(m_pElements, pElement);
|
||||
pElement->m_pObject->release();
|
||||
CC_SAFE_DELETE(pElement);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDictionary::removeObjectForKey(int key)
|
||||
{
|
||||
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as its key");
|
||||
CCDictElement *pElement = NULL;
|
||||
HASH_FIND_INT(m_pElements, &key, pElement);
|
||||
if (pElement != NULL)
|
||||
{
|
||||
HASH_DEL(m_pElements, pElement);
|
||||
pElement->m_pObject->release();
|
||||
CC_SAFE_DELETE(pElement);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDictionary::removeAllObjects()
|
||||
{
|
||||
CCDictElement *pElement, *tmp;
|
||||
HASH_ITER(hh, m_pElements, pElement, tmp)
|
||||
{
|
||||
HASH_DEL(m_pElements, pElement);
|
||||
pElement->m_pObject->release();
|
||||
CC_SAFE_DELETE(pElement);
|
||||
}
|
||||
}
|
||||
|
||||
CCObject* CCDictionary::copyWithZone(CCZone* pZone)
|
||||
{
|
||||
CCDictionary* pNewDict = new CCDictionary();
|
||||
|
||||
CCDictElement* pElement = NULL;
|
||||
if (m_eDictType == kCCDictInt)
|
||||
{
|
||||
CCDICT_FOREACH(this, pElement)
|
||||
{
|
||||
pNewDict->setObject(pElement->getObject(), pElement->getIntKey());
|
||||
}
|
||||
}
|
||||
else if (m_eDictType == kCCDictStr)
|
||||
{
|
||||
CCDICT_FOREACH(this, pElement)
|
||||
{
|
||||
pNewDict->setObject(pElement->getObject(), pElement->getStrKey());
|
||||
}
|
||||
}
|
||||
|
||||
return pNewDict;
|
||||
}
|
||||
|
||||
/* need deep copy ?*/
|
||||
|
||||
CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict)
|
||||
{
|
||||
CCDictionary* pNewDict = (CCDictionary*)srcDict->copyWithZone(NULL);
|
||||
pNewDict->autorelease();
|
||||
return pNewDict;
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -23,6 +23,8 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCNotificationCenter.h"
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ THE SOFTWARE.
|
|||
#include "CCProtocols.h"
|
||||
#include "CCSpriteFrame.h"
|
||||
#include "CCAnimation.h"
|
||||
#include <vector>
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
@brief An interval action is an action that takes place within a certain period of time.
|
||||
|
@ -717,8 +718,6 @@ private:
|
|||
CCFiniteTimeAction* m_pAction;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif //__ACTION_CCINTERVAL_ACTION_H__
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#define __ACTION_CCACTION_MANAGER_H__
|
||||
|
||||
#include "CCAction.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCObject.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
|
|
@ -28,8 +28,8 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCPlatformConfig.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "CCSpriteFrame.h"
|
||||
#include <string>
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
virtual ~CCAnimationFrame();
|
||||
virtual CCObject* copyWithZone(CCZone* pZone);
|
||||
/** initializes the animation frame with a spriteframe, number of delay units and a notification user info */
|
||||
bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCObjectDictionary* userInfo);
|
||||
bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo);
|
||||
|
||||
/** CCSpriteFrameName to be used */
|
||||
CC_SYNTHESIZE_RETAIN(CCSpriteFrame*, m_pSpriteFrame, SpriteFrame)
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
CC_SYNTHESIZE(float, m_fDelayUnits, DelayUnits)
|
||||
|
||||
/** A CCAnimationFrameDisplayedNotification notification will be broadcasted when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcasted. */
|
||||
CC_SYNTHESIZE_RETAIN(CCObjectDictionary*, m_pUserInfo, UserInfo)
|
||||
CC_SYNTHESIZE_RETAIN(CCDictionary*, m_pUserInfo, UserInfo)
|
||||
};
|
||||
|
||||
|
||||
|
@ -92,18 +92,18 @@ public:
|
|||
The frames will be created with one "delay unit".
|
||||
@since v0.99.5
|
||||
*/
|
||||
static CCAnimation* animationWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *arrayOfSpriteFrameNames);
|
||||
static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames);
|
||||
|
||||
/* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds.
|
||||
The frames will be added with one "delay unit".
|
||||
@since v0.99.5
|
||||
*/
|
||||
static CCAnimation* animationWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *arrayOfSpriteFrameNames, float delay);
|
||||
static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay);
|
||||
|
||||
/* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed.
|
||||
@since v2.0
|
||||
*/
|
||||
static CCAnimation* animationWithAnimationFrames(CCMutableArray<CCAnimationFrame*> *arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops);
|
||||
static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops);
|
||||
|
||||
/** Adds a CCSpriteFrame to a CCAnimation.
|
||||
The frame will be added with one "delay unit".
|
||||
|
@ -126,17 +126,17 @@ public:
|
|||
/** Initializes a CCAnimation with frames.
|
||||
@since v0.99.5
|
||||
*/
|
||||
bool initWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *pFrames);
|
||||
bool initWithSpriteFrames(CCArray *pFrames);
|
||||
|
||||
/** Initializes a CCAnimation with frames and a delay between frames
|
||||
@since v0.99.5
|
||||
*/
|
||||
bool initWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay);
|
||||
bool initWithSpriteFrames(CCArray *pFrames, float delay);
|
||||
|
||||
/** Initializes a CCAnimation with CCAnimationFrame
|
||||
@since v2.0
|
||||
*/
|
||||
bool initWithAnimationFrames(CCMutableArray<CCAnimationFrame*>* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops);
|
||||
bool initWithAnimationFrames(CCArray* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops);
|
||||
|
||||
virtual CCObject* copyWithZone(CCZone* pZone);
|
||||
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
CC_PROPERTY_READONLY(float, m_fDuration, Duration)
|
||||
|
||||
/** array of CCAnimationFrames */
|
||||
CC_SYNTHESIZE_RETAIN(CCMutableArray<CCAnimationFrame*>*, m_pFrames, Frames)
|
||||
CC_SYNTHESIZE_RETAIN(CCArray*, m_pFrames, Frames)
|
||||
|
||||
/** whether or not it shall restore the original frame when the animation finishes */
|
||||
CC_SYNTHESIZE(bool, m_bRestoreOriginalFrame, RestoreOriginalFrame)
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#define __CC_ANIMATION_CACHE_H__
|
||||
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
Make sure that the frames were previously loaded in the CCSpriteFrameCache.
|
||||
@since v1.1
|
||||
*/
|
||||
void addAnimationsWithDictionary(CCObjectDictionary* dictionary);
|
||||
void addAnimationsWithDictionary(CCDictionary* dictionary);
|
||||
|
||||
/** Adds an animation from a plist file.
|
||||
Make sure that the frames were previously loaded in the CCSpriteFrameCache.
|
||||
|
@ -83,11 +83,11 @@ public:
|
|||
bool init(void);
|
||||
|
||||
private:
|
||||
void parseVersion1(CCObjectDictionary* animations);
|
||||
void parseVersion2(CCObjectDictionary* animations);
|
||||
const char * valueForKey(const char *key, CCObjectDictionary* dict);
|
||||
void parseVersion1(CCDictionary* animations);
|
||||
void parseVersion2(CCDictionary* animations);
|
||||
const char * valueForKey(const char *key, CCDictionary* dict);
|
||||
private:
|
||||
CCMutableDictionary<std::string, CCAnimation*>* m_pAnimations;
|
||||
CCDictionary* m_pAnimations;
|
||||
static CCAnimationCache* s_pSharedAnimationCache;
|
||||
};
|
||||
|
||||
|
|
|
@ -49,8 +49,25 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0
|
|||
arr <= end && ((__object__ = *arr) != NULL/* || true*/); \
|
||||
arr++)
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
#define CCARRAY_FOREACH_REVERSE(__array__, __object__) \
|
||||
if (__array__ && __array__->data->num > 0) \
|
||||
for(CCObject** arr = __array__->data->arr + __array__->data->num-1, **end = __array__->data->arr; \
|
||||
arr >= end && ((__object__ = *arr) != NULL/* || true*/); \
|
||||
arr--)
|
||||
|
||||
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
|
||||
#define CCARRAY_VERIFY_TYPE(__array__, __type__) \
|
||||
do { \
|
||||
if (__array__ && __array__->data->num > 0) \
|
||||
for(CCObject** arr = __array__->data->arr, **end = __array__->data->arr + __array__->data->num-1; arr <= end; arr++) \
|
||||
CCAssert(dynamic_cast<__type__>(*arr), "element type is wrong!"); \
|
||||
} while(false)
|
||||
#else
|
||||
#define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0)
|
||||
#endif
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL CCArray : public CCObject
|
||||
{
|
||||
|
@ -99,11 +116,11 @@ public:
|
|||
// Removing Objects
|
||||
|
||||
/** Remove last object */
|
||||
void removeLastObject();
|
||||
void removeLastObject(bool bReleaseObj = true);
|
||||
/** Remove a certain object */
|
||||
void removeObject(CCObject* object);
|
||||
void removeObject(CCObject* object, bool bReleaseObj = true);
|
||||
/** Remove an element with a certain index */
|
||||
void removeObjectAtIndex(unsigned int index);
|
||||
void removeObjectAtIndex(unsigned int index, bool bReleaseObj = true);
|
||||
/** Remove all elements */
|
||||
void removeObjectsInArray(CCArray* otherArray);
|
||||
/** Remove all objects */
|
||||
|
@ -124,13 +141,15 @@ public:
|
|||
/* Shrinks the array so the memory footprint corresponds with the number of items */
|
||||
void reduceMemoryFootprint();
|
||||
|
||||
void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true);
|
||||
|
||||
/** TODO: deep copy array. */
|
||||
virtual CCObject* copyWithZone(CCZone* pZone) {CCAssert(false, "");return NULL;}
|
||||
public:
|
||||
ccArray* data;
|
||||
|
||||
private:
|
||||
CCArray() : data(NULL) {};
|
||||
};
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCARRAY_H__
|
||||
|
|
|
@ -25,12 +25,13 @@ THE SOFTWARE.
|
|||
#define __AUTORELEASEPOOL_H__
|
||||
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace cocos2d {
|
||||
class CC_DLL CCAutoreleasePool : public CCObject
|
||||
{
|
||||
CCMutableArray<CCObject*>* m_pManagedObjectArray;
|
||||
CCArray* m_pManagedObjectArray;
|
||||
public:
|
||||
CCAutoreleasePool(void);
|
||||
~CCAutoreleasePool(void);
|
||||
|
@ -43,7 +44,7 @@ public:
|
|||
|
||||
class CC_DLL CCPoolManager
|
||||
{
|
||||
CCMutableArray<CCAutoreleasePool*>* m_pReleasePoolStack;
|
||||
CCArray* m_pReleasePoolStack;
|
||||
CCAutoreleasePool* m_pCurReleasePool;
|
||||
|
||||
CCAutoreleasePool* getCurReleasePool();
|
||||
|
@ -62,6 +63,6 @@ public:
|
|||
friend class CCAutoreleasePool;
|
||||
};
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif //__AUTORELEASEPOOL_H__
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
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 __CCDICTIONARY_H__
|
||||
#define __CCDICTIONARY_H__
|
||||
|
||||
#include "support/data_support/uthash.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCDictionary;
|
||||
|
||||
class CC_DLL CCDictElement
|
||||
{
|
||||
public:
|
||||
CCDictElement(const char* pszKey, CCObject* pObject)
|
||||
{
|
||||
init();
|
||||
strncpy(m_szKey, pszKey, sizeof(m_szKey));
|
||||
m_pObject = pObject;
|
||||
}
|
||||
|
||||
CCDictElement(int iKey, CCObject* pObject)
|
||||
{
|
||||
init();
|
||||
m_iKey = iKey;
|
||||
m_pObject = pObject;
|
||||
}
|
||||
|
||||
inline const char* getStrKey() const
|
||||
{
|
||||
return m_szKey;
|
||||
}
|
||||
|
||||
inline int getIntKey() const
|
||||
{
|
||||
return m_iKey;
|
||||
}
|
||||
|
||||
inline CCObject* getObject() const
|
||||
{
|
||||
return m_pObject;
|
||||
}
|
||||
|
||||
private:
|
||||
inline void init()
|
||||
{
|
||||
m_iKey = 0;
|
||||
m_pObject = NULL;
|
||||
memset(m_szKey, 0, sizeof(m_szKey));
|
||||
memset(&hh, 0, sizeof(hh));
|
||||
}
|
||||
|
||||
private:
|
||||
char m_szKey[256]; /* hash key of string type*/
|
||||
int m_iKey; /* hash key of integer type */
|
||||
CCObject* m_pObject;/* hash value */
|
||||
public:
|
||||
UT_hash_handle hh; /* makes this class hashable */
|
||||
friend class CCDictionary;
|
||||
};
|
||||
|
||||
|
||||
// #define CCDICT_FOREACH(__dict__, pElement) \
|
||||
// for (pElement = __dict__->m_pElements; pElement != NULL; \
|
||||
// pElement = (CCDictElement*)pElement->hh.next)
|
||||
|
||||
#define CCDICT_FOREACH(__dict__, __el__) \
|
||||
CCDictElement* ##__dict__##__el__##tmp = NULL; \
|
||||
HASH_ITER(hh, (__dict__)->m_pElements, __el__, ##__dict__##__el__##tmp)
|
||||
|
||||
|
||||
class CC_DLL CCDictionary : public CCObject
|
||||
{
|
||||
public:
|
||||
CCDictionary();
|
||||
~CCDictionary();
|
||||
|
||||
/// return the number of items
|
||||
unsigned int count();
|
||||
|
||||
/// return all the keys
|
||||
CCArray* allKeys();
|
||||
|
||||
/** @warning : We use '==' to compare two objects*/
|
||||
CCArray* allKeysForObject(CCObject* object);
|
||||
|
||||
CCObject* objectForKey(const char* key);
|
||||
CCObject* objectForKey(int key);
|
||||
|
||||
bool setObject(CCObject* pObject, const char* key);
|
||||
bool setObject(CCObject* pObject, int key);
|
||||
|
||||
void removeObjectForKey(const char* key);
|
||||
void removeObjectForKey(int key);
|
||||
|
||||
void removeAllObjects();
|
||||
|
||||
virtual CCObject* copyWithZone(CCZone* pZone);
|
||||
static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict);
|
||||
|
||||
public:
|
||||
CCDictElement* m_pElements;
|
||||
private:
|
||||
enum CCDictType
|
||||
{
|
||||
kCCDictUnknown = 0,
|
||||
kCCDictStr,
|
||||
kCCDictInt
|
||||
};
|
||||
CCDictType m_eDictType;
|
||||
CCDictType m_eOldDictType;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* __CCDICTIONARY_H__ */
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
#include "CCObject.h"
|
||||
#include "ccTypes.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGL.h"
|
||||
|
@ -448,7 +448,7 @@ protected:
|
|||
bool m_bSendCleanupToScene;
|
||||
|
||||
/* scheduled scenes */
|
||||
CCMutableArray<CCScene*> *m_pobScenesStack;
|
||||
CCArray* m_pobScenesStack;
|
||||
|
||||
/* last time the main loop was updated */
|
||||
struct cc_timeval *m_pLastUpdate;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef __CCINTEGER_H__
|
||||
#define __CCINTEGER_H__
|
||||
|
||||
#include "CCObject.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL CCInteger : public CCObject
|
||||
{
|
||||
public:
|
||||
CCInteger(int v)
|
||||
: value(v) {}
|
||||
int value;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* __CCINTEGER_H__ */
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
#define __CCKEYPAD_DISPATCHER_H__
|
||||
|
||||
#include "CCKeypadDelegate.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
@ -84,9 +84,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
typedef CCMutableArray<CCKeypadHandler*> KeypadDelegateArray;
|
||||
|
||||
KeypadDelegateArray* m_pDelegates;
|
||||
CCArray* m_pDelegates;
|
||||
bool m_bLocked;
|
||||
bool m_bToAdd;
|
||||
bool m_bToRemove;
|
||||
|
|
|
@ -32,7 +32,7 @@ THE SOFTWARE.
|
|||
#include "CCTouchDelegateProtocol.h"
|
||||
#include "CCAccelerometerDelegate.h"
|
||||
#include "CCKeypadDelegate.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
@ -272,7 +272,7 @@ class CC_DLL CCLayerMultiplex : public CCLayer
|
|||
{
|
||||
protected:
|
||||
unsigned int m_nEnabledLayer;
|
||||
CCMutableArray<CCLayer *> * m_pLayers;
|
||||
CCArray* m_pLayers;
|
||||
public:
|
||||
|
||||
CCLayerMultiplex();
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCNode.h"
|
||||
#include "CCProtocols.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d{
|
||||
|
||||
|
@ -287,7 +287,7 @@ namespace cocos2d{
|
|||
/** CCMutableArray that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one.
|
||||
@since v0.7.2
|
||||
*/
|
||||
CC_PROPERTY(CCMutableArray<CCMenuItem*>*, m_pSubItems, SubItems);
|
||||
CC_PROPERTY(CCArray*, m_pSubItems, SubItems);
|
||||
public:
|
||||
CCMenuItemToggle()
|
||||
: m_cOpacity(0)
|
||||
|
|
|
@ -1,363 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
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 __COCOA_CC_MUTABLE_ARRAY_H__
|
||||
#define __COCOA_CC_MUTABLE_ARRAY_H__
|
||||
|
||||
#include "CCObject.h"
|
||||
#include "ccMacros.h"
|
||||
#include <vector>
|
||||
#include <stdarg.h>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
// the element should be pointer of CCObject or it's sub class
|
||||
template<class T = CCObject*>
|
||||
class CCMutableArray : public CCObject
|
||||
{
|
||||
public:
|
||||
typedef std::vector<T> CCObjectArray;
|
||||
typedef typename CCObjectArray::iterator CCMutableArrayIterator;
|
||||
typedef typename CCObjectArray::reverse_iterator CCMutableArrayRevIterator;
|
||||
|
||||
public:
|
||||
CCMutableArray(unsigned int uSize = 0)
|
||||
{
|
||||
if (uSize != 0)
|
||||
m_array.reserve(uSize);
|
||||
}
|
||||
|
||||
virtual ~CCMutableArray(void)
|
||||
{
|
||||
removeAllObjects();
|
||||
}
|
||||
|
||||
inline unsigned int count(void)
|
||||
{
|
||||
return (unsigned int)m_array.size();
|
||||
}
|
||||
|
||||
bool containsObject(T pObject)
|
||||
{
|
||||
if (m_array.empty() || (! pObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bRet = false;
|
||||
CCMutableArrayIterator iter;
|
||||
for (iter = m_array.begin(); iter != m_array.end(); ++iter)
|
||||
{
|
||||
if (*iter == pObject)
|
||||
{
|
||||
bRet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
T getLastObject(void)
|
||||
{
|
||||
CCMutableArrayRevIterator iter = rbegin();
|
||||
|
||||
if (iter != m_array.rend())
|
||||
return *iter;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
T getObjectAtIndex(unsigned int uIndex)
|
||||
{
|
||||
CCAssert(uIndex < count(), "");
|
||||
|
||||
if (uIndex >= count())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_array[uIndex];
|
||||
}
|
||||
|
||||
// Adding objects
|
||||
void addObject(T pObject)
|
||||
{
|
||||
// make sure the pointer is not null
|
||||
if (pObject == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// add the refrence
|
||||
pObject->retain();
|
||||
|
||||
m_array.push_back(pObject);
|
||||
}
|
||||
|
||||
void addObjectsFromArray(CCMutableArray<T> *pArray)
|
||||
{
|
||||
if (pArray && pArray->count() > 0)
|
||||
{
|
||||
m_array.reserve(count() + pArray->count());
|
||||
CCMutableArrayIterator iter;
|
||||
for (iter = pArray->begin(); iter != pArray->end(); ++iter)
|
||||
{
|
||||
if (*iter)
|
||||
(*iter)->retain();
|
||||
m_array.push_back(*iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void insertObjectAtIndex(T pObject, unsigned int uIndex)
|
||||
{
|
||||
CCAssert(uIndex <= count(), "");
|
||||
// make sure the object is not null
|
||||
if (pObject == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// add the reference of the object
|
||||
pObject->retain();
|
||||
|
||||
// resize the capacity if the index out of it
|
||||
if (uIndex >= m_array.capacity())
|
||||
{
|
||||
m_array.reserve(uIndex + 1);
|
||||
m_array.push_back(pObject);
|
||||
}
|
||||
else // insert the object
|
||||
m_array.insert(m_array.begin() + uIndex, pObject);
|
||||
}
|
||||
|
||||
// Removing objects
|
||||
void removeLastObject(bool bDeleteObject = true)
|
||||
{
|
||||
CCMutableArrayRevIterator it = m_array.rbegin();
|
||||
if (it != m_array.rend())
|
||||
{
|
||||
if (bDeleteObject)
|
||||
(*it)->release();
|
||||
m_array.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void removeObject(T pObject, bool bDeleteObject = true)
|
||||
{
|
||||
if (m_array.empty() || (! pObject))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CCMutableArrayIterator iter;
|
||||
int i;
|
||||
for (iter = m_array.begin(), i = 0; iter != m_array.end(); ++iter, ++i)
|
||||
{
|
||||
if (*iter == pObject)
|
||||
{
|
||||
m_array.erase(iter);
|
||||
|
||||
if (bDeleteObject)
|
||||
{
|
||||
pObject->release();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeObjectsInArray(CCMutableArray<T>* pDeleteArray)
|
||||
{
|
||||
if(pDeleteArray && pDeleteArray->count())
|
||||
{
|
||||
CCMutableArrayIterator it;
|
||||
for( it = pDeleteArray->m_array.begin(); it != pDeleteArray->m_array.end(); ++it)
|
||||
{
|
||||
removeObject(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeObjectAtIndex(unsigned int uIndex, bool bDeleteObject = true)
|
||||
{
|
||||
if (m_array.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bDeleteObject)
|
||||
{
|
||||
T pObject = m_array.at(uIndex);
|
||||
if (pObject)
|
||||
{
|
||||
pObject->release();
|
||||
}
|
||||
}
|
||||
|
||||
m_array.erase(m_array.begin() + uIndex);
|
||||
}
|
||||
|
||||
void removeAllObjects(bool bDeleteObject = true)
|
||||
{
|
||||
if (bDeleteObject)
|
||||
{
|
||||
CCMutableArrayIterator iter;
|
||||
for (iter = m_array.begin(); iter != m_array.end(); ++iter)
|
||||
(*iter)->release();
|
||||
}
|
||||
|
||||
m_array.clear();
|
||||
}
|
||||
|
||||
void replaceObjectAtIndex(unsigned int uIndex, T pObject, bool bDeleteObject = true)
|
||||
{
|
||||
if (bDeleteObject && m_array[uIndex])
|
||||
{
|
||||
m_array[uIndex]->release();
|
||||
}
|
||||
|
||||
m_array[uIndex] = pObject;
|
||||
|
||||
// add the ref
|
||||
if (pObject)
|
||||
{
|
||||
pObject->retain();
|
||||
}
|
||||
}
|
||||
|
||||
inline CCMutableArrayIterator begin(void)
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
|
||||
inline CCMutableArrayRevIterator rbegin(void)
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
|
||||
CCMutableArrayIterator getLastValidIterator(void)
|
||||
{
|
||||
CCMutableArrayIterator iter;
|
||||
CCMutableArrayIterator ret;
|
||||
for (iter = m_array.begin(); iter != m_array.end(); ++iter)
|
||||
{
|
||||
ret = iter;
|
||||
if (! (*iter))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* end is a keyword of lua, so should use other name
|
||||
* to export to lua
|
||||
*/
|
||||
inline CCMutableArrayIterator endToLua(void)
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
|
||||
inline CCMutableArrayIterator end(void)
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
|
||||
inline CCMutableArrayRevIterator rend(void)
|
||||
{
|
||||
return m_array.rend();
|
||||
}
|
||||
|
||||
CCMutableArray<T>* copy(void)
|
||||
{
|
||||
CCMutableArray* pArray = new CCMutableArray();
|
||||
|
||||
pArray->m_array.assign(m_array.begin(), m_array.end());
|
||||
|
||||
if(pArray->count() > 0)
|
||||
{
|
||||
CCMutableArrayIterator it;
|
||||
for(it = pArray->begin(); it != pArray->end(); ++it)
|
||||
{
|
||||
if(*it)
|
||||
{
|
||||
(*it)->retain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pArray;
|
||||
}
|
||||
|
||||
public:
|
||||
static CCMutableArray<T>* arrayWithObjects(T pObject1, ...)
|
||||
{
|
||||
CCMutableArray<T> *pArray = new CCMutableArray<T>();
|
||||
pArray->autorelease();
|
||||
|
||||
va_list params;
|
||||
va_start(params, pObject1);
|
||||
|
||||
T pFirst = pObject1;
|
||||
while (pFirst)
|
||||
{
|
||||
pArray->addObject(pFirst);
|
||||
pFirst = va_arg(params, T);
|
||||
}
|
||||
|
||||
va_end(params);
|
||||
|
||||
return pArray;
|
||||
}
|
||||
|
||||
static CCMutableArray<T>* arrayWithArray(CCMutableArray<T> *pSrcArray)
|
||||
{
|
||||
CCMutableArray<T> *pDestArray = 0;
|
||||
|
||||
if (pSrcArray == 0)
|
||||
{
|
||||
pDestArray = new CCMutableArray<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
pDestArray = pSrcArray->copy();
|
||||
}
|
||||
|
||||
pDestArray->autorelease();
|
||||
|
||||
return pDestArray;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T> m_array;
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __COCOA_CC_MUTABLE_ARRAY_H__
|
|
@ -1,241 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
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 __CCMUTABLE_DICTIONARY_H__
|
||||
#define __CCMUTABLE_DICTIONARY_H__
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
using namespace std;
|
||||
namespace cocos2d {
|
||||
class CCString;
|
||||
|
||||
template<class _KeyT, class _ValueT = CCObject*>
|
||||
class CCMutableDictionary : public CCObject
|
||||
{
|
||||
public:
|
||||
typedef std::map<_KeyT, _ValueT> CCObjectMap;
|
||||
typedef typename CCObjectMap::iterator CCObjectMapIter;
|
||||
|
||||
protected:
|
||||
typedef pair<_KeyT, _ValueT> Int_Pair;
|
||||
CCObjectMap m_Map;
|
||||
bool m_bBegin;
|
||||
CCObjectMapIter m_MapIter;
|
||||
|
||||
public:
|
||||
CCMutableDictionary(void)
|
||||
{
|
||||
m_bBegin = false;
|
||||
}
|
||||
|
||||
~CCMutableDictionary(void)
|
||||
{
|
||||
removeAllObjects();
|
||||
}
|
||||
|
||||
/// return the number of items
|
||||
unsigned int count()
|
||||
{
|
||||
return m_Map.size();
|
||||
}
|
||||
|
||||
/// return all the keys
|
||||
std::vector<_KeyT> allKeys()
|
||||
{
|
||||
std::vector<_KeyT> tRet;
|
||||
if (m_Map.size() > 0)
|
||||
{
|
||||
CCObjectMapIter it;
|
||||
for( it = m_Map.begin(); it != m_Map.end(); ++it)
|
||||
{
|
||||
tRet.push_back(it->first);
|
||||
}
|
||||
}
|
||||
return tRet;
|
||||
}
|
||||
|
||||
/** @warning : We use '==' to compare two objects*/
|
||||
std::vector<_KeyT> allKeysForObject(_ValueT object)
|
||||
{
|
||||
std::vector<_KeyT> tRet;
|
||||
if (m_Map.size() > 0)
|
||||
{
|
||||
CCObjectMapIter it;
|
||||
for( it= m_Map.begin(); it != m_Map.end(); ++it)
|
||||
{
|
||||
if (it->second == object)
|
||||
{
|
||||
tRet.push_back(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tRet;
|
||||
}
|
||||
|
||||
_ValueT objectForKey(const _KeyT& key) ///<
|
||||
{
|
||||
CCObjectMapIter it;
|
||||
|
||||
it = m_Map.find(key);
|
||||
|
||||
if(it == m_Map.end()) //no match case
|
||||
return NULL;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool setObject(_ValueT pObject, const _KeyT& key)
|
||||
{
|
||||
pair<CCObjectMapIter, bool > pr;
|
||||
|
||||
pr = m_Map.insert( Int_Pair(key, pObject) );
|
||||
|
||||
if(pr.second == true)
|
||||
{
|
||||
pObject->retain();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void removeObjectForKey(const _KeyT& key)
|
||||
{
|
||||
CCObjectMapIter it;
|
||||
|
||||
it = m_Map.find(key);
|
||||
|
||||
if(it == m_Map.end()) //no match case
|
||||
return;
|
||||
|
||||
if(it->second )
|
||||
{
|
||||
it->second->release() ;
|
||||
m_Map.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
bool begin()
|
||||
{
|
||||
if(m_Map.size() == 0)
|
||||
return false;
|
||||
|
||||
m_MapIter = m_Map.begin();
|
||||
m_bBegin = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_ValueT next(_KeyT* key = NULL)
|
||||
{
|
||||
if(!m_bBegin)
|
||||
return NULL;
|
||||
|
||||
_ValueT pObject = m_MapIter->second;
|
||||
|
||||
if(m_MapIter == m_Map.end())
|
||||
{
|
||||
m_bBegin = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(key)
|
||||
{
|
||||
*key = m_MapIter->first;
|
||||
}
|
||||
|
||||
++m_MapIter;
|
||||
|
||||
if(m_MapIter == m_Map.end())
|
||||
{
|
||||
m_bBegin = false;
|
||||
}
|
||||
}
|
||||
|
||||
return pObject;
|
||||
}
|
||||
|
||||
/*
|
||||
* end is a keyword of lua, so should use other name
|
||||
* to export to lua
|
||||
*/
|
||||
void endToLua()
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
m_bBegin = false;
|
||||
}
|
||||
|
||||
void removeAllObjects()
|
||||
{
|
||||
if (m_Map.size() > 0)
|
||||
{
|
||||
CCObjectMapIter it;
|
||||
for( it = m_Map.begin(); it != m_Map.end(); ++it)
|
||||
{
|
||||
if (it->second)
|
||||
{
|
||||
it->second->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Map.clear();
|
||||
}
|
||||
|
||||
static CCMutableDictionary<_KeyT, _ValueT>* dictionaryWithDictionary(CCMutableDictionary<_KeyT, _ValueT>* srcDict)
|
||||
{
|
||||
CCMutableDictionary<_KeyT, _ValueT>* pNewDict = new CCMutableDictionary<_KeyT, _ValueT>();
|
||||
|
||||
srcDict->begin();
|
||||
|
||||
_KeyT key;
|
||||
_ValueT value;
|
||||
|
||||
while( (value = srcDict->next(&key)) )
|
||||
{
|
||||
pNewDict->setObject(value, key);
|
||||
}
|
||||
|
||||
srcDict->end();
|
||||
|
||||
return pNewDict;
|
||||
}
|
||||
};
|
||||
|
||||
#define CCDictionary CCMutableDictionary
|
||||
typedef CCDictionary<std::string, CCString*> CCStringToStringDictionary;
|
||||
typedef CCDictionary<std::string, CCObject*> CCObjectDictionary;
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
|
||||
#endif //__CCMUTABLE_DICTIONARY_H__
|
|
@ -28,10 +28,10 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCProtocols.h"
|
||||
#include "CCNode.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCString.h"
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCParticleBatchNode;
|
||||
|
||||
|
@ -370,7 +370,7 @@ public:
|
|||
/** initializes a CCQuadParticleSystem from a CCDictionary.
|
||||
@since v0.99.3
|
||||
*/
|
||||
bool initWithDictionary(CCDictionary<std::string, CCObject*> *dictionary);
|
||||
bool initWithDictionary(CCDictionary *dictionary);
|
||||
|
||||
//! Initializes a system with a fixed number of particles
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -396,17 +396,17 @@ private:
|
|||
/** Private method, return the string found by key in dict.
|
||||
@return "" if not found; return the string if found.
|
||||
*/
|
||||
inline const char * valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict)
|
||||
inline const char * valueForKey(const char *key, CCDictionary *dict)
|
||||
{
|
||||
if (dict)
|
||||
{
|
||||
CCString *pString = (CCString*)dict->objectForKey(std::string(key));
|
||||
CCString *pString = (CCString*)dict->objectForKey(key);
|
||||
return pString ? pString->m_sString.c_str() : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
}// namespace cocos2d
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCPARTICLE_SYSTEM_H__
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#ifndef __CCSHADERCACHE_H__
|
||||
#define __CCSHADERCACHE_H__
|
||||
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
private:
|
||||
bool init();
|
||||
|
||||
CCMutableDictionary<std::string, CCGLProgram*>* m_pPrograms;
|
||||
CCDictionary* m_pPrograms;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
#include "CCProtocols.h"
|
||||
#include "CCTextureAtlas.h"
|
||||
#include "ccTypes.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
#include <string>
|
||||
namespace cocos2d {
|
||||
|
|
|
@ -32,7 +32,7 @@ THE SOFTWARE.
|
|||
#include "CCProtocols.h"
|
||||
#include "CCTextureAtlas.h"
|
||||
#include "ccMacros.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ THE SOFTWARE.
|
|||
#include "CCSpriteFrame.h"
|
||||
#include "CCTexture2D.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
namespace cocos2d {
|
||||
class CCSprite;
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
/*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
|
||||
*/
|
||||
void addSpriteFramesWithDictionary(CCDictionary<std::string, CCObject*> *pobDictionary, CCTexture2D *pobTexture);
|
||||
void addSpriteFramesWithDictionary(CCDictionary* pobDictionary, CCTexture2D *pobTexture);
|
||||
|
||||
/** Adds multiple Sprite Frames from a plist file.
|
||||
* A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
/** Removes multiple Sprite Frames from CCDictionary.
|
||||
* @since v0.99.5
|
||||
*/
|
||||
void removeSpriteFramesFromDictionary(CCDictionary<std::string, CCSpriteFrame*> *dictionary);
|
||||
void removeSpriteFramesFromDictionary(CCDictionary* dictionary);
|
||||
|
||||
/** Removes all Sprite Frames associated with the specified textures.
|
||||
* It is convinient to call this method when a specific texture needs to be removed.
|
||||
|
@ -126,11 +126,11 @@ public:
|
|||
|
||||
private:
|
||||
CCSpriteFrameCache(void) : m_pSpriteFrames(NULL), m_pSpriteFramesAliases(NULL){}
|
||||
const char * valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict);
|
||||
const char * valueForKey(const char* key, CCDictionary* dict);
|
||||
|
||||
protected:
|
||||
CCDictionary<std::string, CCSpriteFrame*> *m_pSpriteFrames;
|
||||
CCDictionary<std::string, CCString*> *m_pSpriteFramesAliases;
|
||||
CCDictionary* m_pSpriteFrames;
|
||||
CCDictionary* m_pSpriteFramesAliases;
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ namespace cocos2d {
|
|||
return m_sString;
|
||||
}
|
||||
|
||||
const char* c_str()
|
||||
{
|
||||
return m_sString.c_str();
|
||||
}
|
||||
|
||||
bool isEmpty()
|
||||
{
|
||||
return m_sString.empty();
|
||||
|
|
|
@ -79,7 +79,7 @@ class CC_DLL CCTMXLayer : public CCSpriteBatchNode
|
|||
/** Layer orientation, which is the same as the map orientation */
|
||||
CC_SYNTHESIZE(unsigned int, m_uLayerOrientation, LayerOrientation);
|
||||
/** properties from the layer. They can be added using Tiled */
|
||||
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
|
||||
CC_PROPERTY(CCDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
CCTMXLayer();
|
||||
virtual ~CCTMXLayer();
|
||||
|
|
|
@ -29,8 +29,8 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCGeometry.h"
|
||||
#include "CCString.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
@ -42,9 +42,9 @@ namespace cocos2d {
|
|||
/** offset position of child objects */
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCPoint, m_tPositionOffset, PositionOffset);
|
||||
/** list of properties stored in a dictionary */
|
||||
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
|
||||
CC_PROPERTY(CCDictionary*, m_pProperties, Properties);
|
||||
/** array of the objects */
|
||||
CC_PROPERTY(CCMutableArray<CCStringToStringDictionary*>*, m_pObjects, Objects);
|
||||
CC_PROPERTY(CCArray*, m_pObjects, Objects);
|
||||
public:
|
||||
CCTMXObjectGroup();
|
||||
virtual ~CCTMXObjectGroup();
|
||||
|
@ -58,7 +58,7 @@ namespace cocos2d {
|
|||
/** return the dictionary for the specific object name.
|
||||
It will return the 1st object found on the array for the given name.
|
||||
*/
|
||||
CCStringToStringDictionary *objectNamed(const char *objectName);
|
||||
CCDictionary* objectNamed(const char *objectName);
|
||||
protected:
|
||||
/** name of the group */
|
||||
std::string m_sGroupName;
|
||||
|
|
|
@ -28,129 +28,130 @@ THE SOFTWARE.
|
|||
#include "CCNode.h"
|
||||
#include "CCTMXObjectGroup.h"
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCTMXObjectGroup;
|
||||
class CCTMXLayer;
|
||||
class CCTMXLayerInfo;
|
||||
class CCTMXTilesetInfo;
|
||||
class CCTMXMapInfo;
|
||||
class CCTMXObjectGroup;
|
||||
class CCTMXLayer;
|
||||
class CCTMXLayerInfo;
|
||||
class CCTMXTilesetInfo;
|
||||
class CCTMXMapInfo;
|
||||
|
||||
/** Possible oritentations of the TMX map */
|
||||
enum
|
||||
{
|
||||
/** Orthogonal orientation */
|
||||
CCTMXOrientationOrtho,
|
||||
/** Possible oritentations of the TMX map */
|
||||
enum
|
||||
{
|
||||
/** Orthogonal orientation */
|
||||
CCTMXOrientationOrtho,
|
||||
|
||||
/** Hexagonal orientation */
|
||||
CCTMXOrientationHex,
|
||||
/** Hexagonal orientation */
|
||||
CCTMXOrientationHex,
|
||||
|
||||
/** Isometric orientation */
|
||||
CCTMXOrientationIso,
|
||||
};
|
||||
/** Isometric orientation */
|
||||
CCTMXOrientationIso,
|
||||
};
|
||||
|
||||
/** @brief CCTMXTiledMap knows how to parse and render a TMX map.
|
||||
/** @brief CCTMXTiledMap knows how to parse and render a TMX map.
|
||||
|
||||
It adds support for the TMX tiled map format used by http://www.mapeditor.org
|
||||
It supports isometric, hexagonal and orthogonal tiles.
|
||||
It also supports object groups, objects, and properties.
|
||||
It adds support for the TMX tiled map format used by http://www.mapeditor.org
|
||||
It supports isometric, hexagonal and orthogonal tiles.
|
||||
It also supports object groups, objects, and properties.
|
||||
|
||||
Features:
|
||||
- Each tile will be treated as an CCSprite
|
||||
- The sprites are created on demand. They will be created only when you call "layer->tileAt(position)"
|
||||
- Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a CCSprite
|
||||
- Tiles can be added/removed in runtime
|
||||
- The z-order of the tiles can be modified in runtime
|
||||
- Each tile has an anchorPoint of (0,0)
|
||||
- The anchorPoint of the TMXTileMap is (0,0)
|
||||
- The TMX layers will be added as a child
|
||||
- The TMX layers will be aliased by default
|
||||
- The tileset image will be loaded using the CCTextureCache
|
||||
- Each tile will have a unique tag
|
||||
- Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
|
||||
- Each object group will be treated as an CCMutableArray
|
||||
- Object class which will contain all the properties in a dictionary
|
||||
- Properties can be assigned to the Map, Layer, Object Group, and Object
|
||||
Features:
|
||||
- Each tile will be treated as an CCSprite
|
||||
- The sprites are created on demand. They will be created only when you call "layer->tileAt(position)"
|
||||
- Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a CCSprite
|
||||
- Tiles can be added/removed in runtime
|
||||
- The z-order of the tiles can be modified in runtime
|
||||
- Each tile has an anchorPoint of (0,0)
|
||||
- The anchorPoint of the TMXTileMap is (0,0)
|
||||
- The TMX layers will be added as a child
|
||||
- The TMX layers will be aliased by default
|
||||
- The tileset image will be loaded using the CCTextureCache
|
||||
- Each tile will have a unique tag
|
||||
- Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
|
||||
- Each object group will be treated as an CCMutableArray
|
||||
- Object class which will contain all the properties in a dictionary
|
||||
- Properties can be assigned to the Map, Layer, Object Group, and Object
|
||||
|
||||
Limitations:
|
||||
- It only supports one tileset per layer.
|
||||
- Embeded images are not supported
|
||||
- It only supports the XML format (the JSON format is not supported)
|
||||
Limitations:
|
||||
- It only supports one tileset per layer.
|
||||
- Embeded images are not supported
|
||||
- It only supports the XML format (the JSON format is not supported)
|
||||
|
||||
Technical description:
|
||||
Each layer is created using an CCTMXLayer (subclass of CCSpriteBatchNode). If you have 5 layers, then 5 CCTMXLayer will be created,
|
||||
unless the layer visibility is off. In that case, the layer won't be created at all.
|
||||
You can obtain the layers (CCTMXLayer objects) at runtime by:
|
||||
- map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
|
||||
- map->layerNamed(name_of_the_layer);
|
||||
Technical description:
|
||||
Each layer is created using an CCTMXLayer (subclass of CCSpriteBatchNode). If you have 5 layers, then 5 CCTMXLayer will be created,
|
||||
unless the layer visibility is off. In that case, the layer won't be created at all.
|
||||
You can obtain the layers (CCTMXLayer objects) at runtime by:
|
||||
- map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
|
||||
- map->layerNamed(name_of_the_layer);
|
||||
|
||||
Each object group is created using a CCTMXObjectGroup which is a subclass of CCMutableArray.
|
||||
You can obtain the object groups at runtime by:
|
||||
- map->objectGroupNamed(name_of_the_object_group);
|
||||
Each object group is created using a CCTMXObjectGroup which is a subclass of CCMutableArray.
|
||||
You can obtain the object groups at runtime by:
|
||||
- map->objectGroupNamed(name_of_the_object_group);
|
||||
|
||||
Each object is a CCTMXObject.
|
||||
Each object is a CCTMXObject.
|
||||
|
||||
Each property is stored as a key-value pair in an CCMutableDictionary.
|
||||
You can obtain the properties at runtime by:
|
||||
Each property is stored as a key-value pair in an CCMutableDictionary.
|
||||
You can obtain the properties at runtime by:
|
||||
|
||||
map->propertyNamed(name_of_the_property);
|
||||
layer->propertyNamed(name_of_the_property);
|
||||
objectGroup->propertyNamed(name_of_the_property);
|
||||
object->propertyNamed(name_of_the_property);
|
||||
map->propertyNamed(name_of_the_property);
|
||||
layer->propertyNamed(name_of_the_property);
|
||||
objectGroup->propertyNamed(name_of_the_property);
|
||||
object->propertyNamed(name_of_the_property);
|
||||
|
||||
@since v0.8.1
|
||||
*/
|
||||
class CC_DLL CCTMXTiledMap : public CCNode
|
||||
{
|
||||
/** the map's size property measured in tiles */
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tMapSize, MapSize);
|
||||
/** the tiles's size property measured in pixels */
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tTileSize, TileSize);
|
||||
/** map orientation */
|
||||
CC_SYNTHESIZE(int, m_nMapOrientation, MapOrientation);
|
||||
/** object groups */
|
||||
CC_PROPERTY(CCMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
|
||||
/** properties */
|
||||
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
CCTMXTiledMap();
|
||||
virtual ~CCTMXTiledMap();
|
||||
@since v0.8.1
|
||||
*/
|
||||
class CC_DLL CCTMXTiledMap : public CCNode
|
||||
{
|
||||
/** the map's size property measured in tiles */
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tMapSize, MapSize);
|
||||
/** the tiles's size property measured in pixels */
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tTileSize, TileSize);
|
||||
/** map orientation */
|
||||
CC_SYNTHESIZE(int, m_nMapOrientation, MapOrientation);
|
||||
/** object groups */
|
||||
CC_PROPERTY(CCArray*, m_pObjectGroups, ObjectGroups);
|
||||
/** properties */
|
||||
CC_PROPERTY(CCDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
CCTMXTiledMap();
|
||||
virtual ~CCTMXTiledMap();
|
||||
|
||||
/** creates a TMX Tiled Map with a TMX file.*/
|
||||
static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile);
|
||||
/** creates a TMX Tiled Map with a TMX file.*/
|
||||
static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile);
|
||||
|
||||
/** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
|
||||
static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
|
||||
static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath);
|
||||
|
||||
/** initializes a TMX Tiled Map with a TMX file */
|
||||
bool initWithTMXFile(const char *tmxFile);
|
||||
/** initializes a TMX Tiled Map with a TMX file */
|
||||
bool initWithTMXFile(const char *tmxFile);
|
||||
|
||||
/** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
|
||||
bool initWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
|
||||
bool initWithXML(const char* tmxString, const char* resourcePath);
|
||||
|
||||
/** return the TMXLayer for the specific layer */
|
||||
CCTMXLayer* layerNamed(const char *layerName);
|
||||
/** return the TMXLayer for the specific layer */
|
||||
CCTMXLayer* layerNamed(const char *layerName);
|
||||
|
||||
/** return the TMXObjectGroup for the secific group */
|
||||
CCTMXObjectGroup* objectGroupNamed(const char *groupName);
|
||||
/** return the TMXObjectGroup for the secific group */
|
||||
CCTMXObjectGroup* objectGroupNamed(const char *groupName);
|
||||
|
||||
/** return the value for the specific property name */
|
||||
CCString *propertyNamed(const char *propertyName);
|
||||
/** return the value for the specific property name */
|
||||
CCString *propertyNamed(const char *propertyName);
|
||||
|
||||
/** return properties dictionary for tile GID */
|
||||
CCDictionary<std::string, CCString*> *propertiesForGID(int GID);
|
||||
/** return properties dictionary for tile GID */
|
||||
CCDictionary* propertiesForGID(int GID);
|
||||
|
||||
private:
|
||||
CCTMXLayer * parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo);
|
||||
CCTMXTilesetInfo * tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo);
|
||||
void buildWithMapInfo(CCTMXMapInfo* mapInfo);
|
||||
protected:
|
||||
//! tile properties
|
||||
CCDictionary<int, CCStringToStringDictionary*> *m_pTileProperties;
|
||||
private:
|
||||
CCTMXLayer * parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo);
|
||||
CCTMXTilesetInfo * tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo);
|
||||
void buildWithMapInfo(CCTMXMapInfo* mapInfo);
|
||||
protected:
|
||||
//! tile properties
|
||||
CCDictionary* m_pTileProperties;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
}// namespace cocos2d
|
||||
#endif //__CCTMX_TILE_MAP_H__
|
||||
|
||||
|
||||
|
|
|
@ -27,186 +27,186 @@ THE SOFTWARE.
|
|||
|
||||
#ifndef __CC_TM_XML_PARSER__
|
||||
#define __CC_TM_XML_PARSER__
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCGeometry.h"
|
||||
|
||||
#include "../platform/CCSAXParser.h"
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCTMXObjectGroup;
|
||||
class CCTMXObjectGroup;
|
||||
|
||||
/** @file
|
||||
* Internal TMX parser
|
||||
*
|
||||
* IMPORTANT: These classed should not be documented using doxygen strings
|
||||
* since the user should not use them.
|
||||
*
|
||||
*/
|
||||
/** @file
|
||||
* Internal TMX parser
|
||||
*
|
||||
* IMPORTANT: These classed should not be documented using doxygen strings
|
||||
* since the user should not use them.
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
TMXLayerAttribNone = 1 << 0,
|
||||
TMXLayerAttribBase64 = 1 << 1,
|
||||
TMXLayerAttribGzip = 1 << 2,
|
||||
TMXLayerAttribZlib = 1 << 3,
|
||||
};
|
||||
enum {
|
||||
TMXLayerAttribNone = 1 << 0,
|
||||
TMXLayerAttribBase64 = 1 << 1,
|
||||
TMXLayerAttribGzip = 1 << 2,
|
||||
TMXLayerAttribZlib = 1 << 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
TMXPropertyNone,
|
||||
TMXPropertyMap,
|
||||
TMXPropertyLayer,
|
||||
TMXPropertyObjectGroup,
|
||||
TMXPropertyObject,
|
||||
TMXPropertyTile
|
||||
};
|
||||
enum {
|
||||
TMXPropertyNone,
|
||||
TMXPropertyMap,
|
||||
TMXPropertyLayer,
|
||||
TMXPropertyObjectGroup,
|
||||
TMXPropertyObject,
|
||||
TMXPropertyTile
|
||||
};
|
||||
|
||||
typedef enum ccTMXTileFlags_ {
|
||||
kCCTMXTileHorizontalFlag = 0x80000000,
|
||||
kCCTMXTileVerticalFlag = 0x40000000,
|
||||
kCCTMXTileDiagonalFlag = 0x20000000,
|
||||
kCCFlipedAll = (kCCTMXTileHorizontalFlag|kCCTMXTileVerticalFlag|kCCTMXTileDiagonalFlag),
|
||||
kCCFlippedMask = ~(kCCFlipedAll)
|
||||
} ccTMXTileFlags;
|
||||
typedef enum ccTMXTileFlags_ {
|
||||
kCCTMXTileHorizontalFlag = 0x80000000,
|
||||
kCCTMXTileVerticalFlag = 0x40000000,
|
||||
kCCTMXTileDiagonalFlag = 0x20000000,
|
||||
kCCFlipedAll = (kCCTMXTileHorizontalFlag|kCCTMXTileVerticalFlag|kCCTMXTileDiagonalFlag),
|
||||
kCCFlippedMask = ~(kCCFlipedAll)
|
||||
} ccTMXTileFlags;
|
||||
|
||||
// Bits on the far end of the 32-bit global tile ID (GID's) are used for tile flags
|
||||
// Bits on the far end of the 32-bit global tile ID (GID's) are used for tile flags
|
||||
|
||||
/** @brief CCTMXLayerInfo contains the information about the layers like:
|
||||
- Layer name
|
||||
- Layer size
|
||||
- Layer opacity at creation time (it can be modified at runtime)
|
||||
- Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
|
||||
/** @brief CCTMXLayerInfo contains the information about the layers like:
|
||||
- Layer name
|
||||
- Layer size
|
||||
- Layer opacity at creation time (it can be modified at runtime)
|
||||
- Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
|
||||
|
||||
This information is obtained from the TMX file.
|
||||
*/
|
||||
class CC_DLL CCTMXLayerInfo : public CCObject
|
||||
{
|
||||
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
std::string m_sName;
|
||||
CCSize m_tLayerSize;
|
||||
unsigned int *m_pTiles;
|
||||
bool m_bVisible;
|
||||
unsigned char m_cOpacity;
|
||||
bool m_bOwnTiles;
|
||||
unsigned int m_uMinGID;
|
||||
unsigned int m_uMaxGID;
|
||||
CCPoint m_tOffset;
|
||||
public:
|
||||
CCTMXLayerInfo();
|
||||
virtual ~CCTMXLayerInfo();
|
||||
};
|
||||
This information is obtained from the TMX file.
|
||||
*/
|
||||
class CC_DLL CCTMXLayerInfo : public CCObject
|
||||
{
|
||||
CC_PROPERTY(CCDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
std::string m_sName;
|
||||
CCSize m_tLayerSize;
|
||||
unsigned int *m_pTiles;
|
||||
bool m_bVisible;
|
||||
unsigned char m_cOpacity;
|
||||
bool m_bOwnTiles;
|
||||
unsigned int m_uMinGID;
|
||||
unsigned int m_uMaxGID;
|
||||
CCPoint m_tOffset;
|
||||
public:
|
||||
CCTMXLayerInfo();
|
||||
virtual ~CCTMXLayerInfo();
|
||||
};
|
||||
|
||||
/** @brief CCTMXTilesetInfo contains the information about the tilesets like:
|
||||
- Tileset name
|
||||
- Tilset spacing
|
||||
- Tileset margin
|
||||
- size of the tiles
|
||||
- Image used for the tiles
|
||||
- Image size
|
||||
/** @brief CCTMXTilesetInfo contains the information about the tilesets like:
|
||||
- Tileset name
|
||||
- Tilset spacing
|
||||
- Tileset margin
|
||||
- size of the tiles
|
||||
- Image used for the tiles
|
||||
- Image size
|
||||
|
||||
This information is obtained from the TMX file.
|
||||
*/
|
||||
class CC_DLL CCTMXTilesetInfo : public CCObject
|
||||
{
|
||||
public:
|
||||
std::string m_sName;
|
||||
unsigned int m_uFirstGid;
|
||||
CCSize m_tTileSize;
|
||||
unsigned int m_uSpacing;
|
||||
unsigned int m_uMargin;
|
||||
//! filename containing the tiles (should be spritesheet / texture atlas)
|
||||
std::string m_sSourceImage;
|
||||
//! size in pixels of the image
|
||||
CCSize m_tImageSize;
|
||||
public:
|
||||
CCTMXTilesetInfo();
|
||||
virtual ~CCTMXTilesetInfo();
|
||||
CCRect rectForGID(unsigned int gid);
|
||||
};
|
||||
This information is obtained from the TMX file.
|
||||
*/
|
||||
class CC_DLL CCTMXTilesetInfo : public CCObject
|
||||
{
|
||||
public:
|
||||
std::string m_sName;
|
||||
unsigned int m_uFirstGid;
|
||||
CCSize m_tTileSize;
|
||||
unsigned int m_uSpacing;
|
||||
unsigned int m_uMargin;
|
||||
//! filename containing the tiles (should be spritesheet / texture atlas)
|
||||
std::string m_sSourceImage;
|
||||
//! size in pixels of the image
|
||||
CCSize m_tImageSize;
|
||||
public:
|
||||
CCTMXTilesetInfo();
|
||||
virtual ~CCTMXTilesetInfo();
|
||||
CCRect rectForGID(unsigned int gid);
|
||||
};
|
||||
|
||||
/** @brief CCTMXMapInfo contains the information about the map like:
|
||||
- Map orientation (hexagonal, isometric or orthogonal)
|
||||
- Tile size
|
||||
- Map size
|
||||
/** @brief CCTMXMapInfo contains the information about the map like:
|
||||
- Map orientation (hexagonal, isometric or orthogonal)
|
||||
- Tile size
|
||||
- Map size
|
||||
|
||||
And it also contains:
|
||||
- Layers (an array of TMXLayerInfo objects)
|
||||
- Tilesets (an array of TMXTilesetInfo objects)
|
||||
- ObjectGroups (an array of TMXObjectGroupInfo objects)
|
||||
And it also contains:
|
||||
- Layers (an array of TMXLayerInfo objects)
|
||||
- Tilesets (an array of TMXTilesetInfo objects)
|
||||
- ObjectGroups (an array of TMXObjectGroupInfo objects)
|
||||
|
||||
This information is obtained from the TMX file.
|
||||
This information is obtained from the TMX file.
|
||||
|
||||
*/
|
||||
class CC_DLL CCTMXMapInfo : public CCObject, public CCSAXDelegator
|
||||
{
|
||||
public:
|
||||
/// map orientation
|
||||
CC_SYNTHESIZE(int, m_nOrientation, Orientation);
|
||||
/// map width & height
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tMapSize, MapSize);
|
||||
/// tiles width & height
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tTileSize, TileSize);
|
||||
/// Layers
|
||||
CC_PROPERTY(CCMutableArray<CCTMXLayerInfo*>*, m_pLayers, Layers);
|
||||
/// tilesets
|
||||
CC_PROPERTY(CCMutableArray<CCTMXTilesetInfo*>*, m_pTilesets, Tilesets);
|
||||
/// ObjectGroups
|
||||
CC_PROPERTY(CCMutableArray<CCTMXObjectGroup*>*, m_pObjectGroups, ObjectGroups);
|
||||
/// parent element
|
||||
CC_SYNTHESIZE(int, m_nParentElement, ParentElement);
|
||||
/// parent GID
|
||||
CC_SYNTHESIZE(unsigned int, m_uParentGID, ParentGID);
|
||||
/// layer attribs
|
||||
CC_SYNTHESIZE(int, m_nLayerAttribs, LayerAttribs);
|
||||
/// is stroing characters?
|
||||
CC_SYNTHESIZE(bool, m_bStoringCharacters, StoringCharacters);
|
||||
/// properties
|
||||
CC_PROPERTY(CCStringToStringDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
CCTMXMapInfo();
|
||||
virtual ~CCTMXMapInfo();
|
||||
/** creates a TMX Format with a tmx file */
|
||||
static CCTMXMapInfo * formatWithTMXFile(const char *tmxFile);
|
||||
/** creates a TMX Format with an XML string and a TMX resource path */
|
||||
static CCTMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initializes a TMX format witha tmx file */
|
||||
bool initWithTMXFile(const char *tmxFile);
|
||||
/** initializes a TMX format with an XML string and a TMX resource path */
|
||||
bool initWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initalises parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file */
|
||||
bool parseXMLFile(const char *xmlFilename);
|
||||
/* initalises parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
|
||||
bool parseXMLString(const char *xmlString);
|
||||
/* handles the work of parsing for parseXMLFile: and parseXMLString: */
|
||||
bool parseXMLData(const char* data);
|
||||
*/
|
||||
class CC_DLL CCTMXMapInfo : public CCObject, public CCSAXDelegator
|
||||
{
|
||||
public:
|
||||
/// map orientation
|
||||
CC_SYNTHESIZE(int, m_nOrientation, Orientation);
|
||||
/// map width & height
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tMapSize, MapSize);
|
||||
/// tiles width & height
|
||||
CC_SYNTHESIZE_PASS_BY_REF(CCSize, m_tTileSize, TileSize);
|
||||
/// Layers
|
||||
CC_PROPERTY(CCArray*, m_pLayers, Layers);
|
||||
/// tilesets
|
||||
CC_PROPERTY(CCArray*, m_pTilesets, Tilesets);
|
||||
/// ObjectGroups
|
||||
CC_PROPERTY(CCArray*, m_pObjectGroups, ObjectGroups);
|
||||
/// parent element
|
||||
CC_SYNTHESIZE(int, m_nParentElement, ParentElement);
|
||||
/// parent GID
|
||||
CC_SYNTHESIZE(unsigned int, m_uParentGID, ParentGID);
|
||||
/// layer attribs
|
||||
CC_SYNTHESIZE(int, m_nLayerAttribs, LayerAttribs);
|
||||
/// is stroing characters?
|
||||
CC_SYNTHESIZE(bool, m_bStoringCharacters, StoringCharacters);
|
||||
/// properties
|
||||
CC_PROPERTY(CCDictionary*, m_pProperties, Properties);
|
||||
public:
|
||||
CCTMXMapInfo();
|
||||
virtual ~CCTMXMapInfo();
|
||||
/** creates a TMX Format with a tmx file */
|
||||
static CCTMXMapInfo * formatWithTMXFile(const char *tmxFile);
|
||||
/** creates a TMX Format with an XML string and a TMX resource path */
|
||||
static CCTMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initializes a TMX format witha tmx file */
|
||||
bool initWithTMXFile(const char *tmxFile);
|
||||
/** initializes a TMX format with an XML string and a TMX resource path */
|
||||
bool initWithXML(const char* tmxString, const char* resourcePath);
|
||||
/** initalises parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file */
|
||||
bool parseXMLFile(const char *xmlFilename);
|
||||
/* initalises parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
|
||||
bool parseXMLString(const char *xmlString);
|
||||
/* handles the work of parsing for parseXMLFile: and parseXMLString: */
|
||||
bool parseXMLData(const char* data);
|
||||
|
||||
CCDictionary<int, CCStringToStringDictionary*> * getTileProperties();
|
||||
void setTileProperties(CCDictionary<int, CCStringToStringDictionary*> * tileProperties);
|
||||
CCDictionary* getTileProperties();
|
||||
void setTileProperties(CCDictionary* tileProperties);
|
||||
|
||||
// implement pure virtual methods of CCSAXDelegator
|
||||
void startElement(void *ctx, const char *name, const char **atts);
|
||||
void endElement(void *ctx, const char *name);
|
||||
void textHandler(void *ctx, const char *ch, int len);
|
||||
|
||||
inline const char* getCurrentString(){ return m_sCurrentString.c_str(); }
|
||||
inline void setCurrentString(const char *currentString){ m_sCurrentString = currentString; }
|
||||
inline const char* getTMXFileName(){ return m_sTMXFileName.c_str(); }
|
||||
inline void setTMXFileName(const char *fileName){ m_sTMXFileName = fileName; }
|
||||
private:
|
||||
void internalInit(const char* tmxFileName, const char* resourcePath);
|
||||
protected:
|
||||
//! tmx filename
|
||||
std::string m_sTMXFileName;
|
||||
// tmx resource path
|
||||
std::string m_sResources;
|
||||
//! current string
|
||||
std::string m_sCurrentString;
|
||||
//! tile properties
|
||||
CCDictionary<int, CCStringToStringDictionary*>* m_pTileProperties;
|
||||
};
|
||||
// implement pure virtual methods of CCSAXDelegator
|
||||
void startElement(void *ctx, const char *name, const char **atts);
|
||||
void endElement(void *ctx, const char *name);
|
||||
void textHandler(void *ctx, const char *ch, int len);
|
||||
|
||||
inline const char* getCurrentString(){ return m_sCurrentString.c_str(); }
|
||||
inline void setCurrentString(const char *currentString){ m_sCurrentString = currentString; }
|
||||
inline const char* getTMXFileName(){ return m_sTMXFileName.c_str(); }
|
||||
inline void setTMXFileName(const char *fileName){ m_sTMXFileName = fileName; }
|
||||
private:
|
||||
void internalInit(const char* tmxFileName, const char* resourcePath);
|
||||
protected:
|
||||
//! tmx filename
|
||||
std::string m_sTMXFileName;
|
||||
// tmx resource path
|
||||
std::string m_sResources;
|
||||
//! current string
|
||||
std::string m_sCurrentString;
|
||||
//! tile properties
|
||||
CCDictionary* m_pTileProperties;
|
||||
};
|
||||
|
||||
}// namespace cocos2d
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
|
||||
#include <string>
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCTexture2D.h"
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ class CCImage;
|
|||
class CC_DLL CCTextureCache : public CCObject
|
||||
{
|
||||
protected:
|
||||
CCMutableDictionary<std::string, CCTexture2D*> * m_pTextures;
|
||||
CCDictionary* m_pTextures;
|
||||
//pthread_mutex_t *m_pDictLock;
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCGL.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCTouchDelegateProtocol.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
namespace cocos2d {
|
||||
|
||||
typedef enum
|
||||
|
@ -146,19 +146,19 @@ public:
|
|||
|
||||
protected:
|
||||
void forceRemoveDelegate(CCTouchDelegate *pDelegate);
|
||||
void forceAddHandler(CCTouchHandler *pHandler, CCMutableArray<CCTouchHandler*> *pArray);
|
||||
void forceAddHandler(CCTouchHandler *pHandler, CCArray* pArray);
|
||||
void forceRemoveAllDelegates(void);
|
||||
void rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray);
|
||||
CCTouchHandler* findHandler(CCMutableArray<CCTouchHandler*> *pArray, CCTouchDelegate *pDelegate);
|
||||
void rearrangeHandlers(CCArray* pArray);
|
||||
CCTouchHandler* findHandler(CCArray* pArray, CCTouchDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
CCMutableArray<CCTouchHandler*> *m_pTargetedHandlers;
|
||||
CCMutableArray<CCTouchHandler*> *m_pStandardHandlers;
|
||||
CCArray* m_pTargetedHandlers;
|
||||
CCArray* m_pStandardHandlers;
|
||||
|
||||
bool m_bLocked;
|
||||
bool m_bToAdd;
|
||||
bool m_bToRemove;
|
||||
CCMutableArray<CCTouchHandler*> *m_pHandlersToAdd;
|
||||
CCArray* m_pHandlersToAdd;
|
||||
struct _ccCArray *m_pHandlersToRemove;
|
||||
bool m_bToQuit;
|
||||
bool m_bDispatchEvents;
|
||||
|
|
|
@ -97,8 +97,8 @@ THE SOFTWARE.
|
|||
// cocoa includes
|
||||
//
|
||||
#include "CCSet.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCZone.h"
|
||||
#include "CCGeometry.h"
|
||||
|
|
|
@ -38,7 +38,8 @@ CCKeypadDispatcher::CCKeypadDispatcher()
|
|||
, m_bToAdd(false)
|
||||
, m_bToRemove(false)
|
||||
{
|
||||
m_pDelegates = new KeypadDelegateArray;
|
||||
m_pDelegates = CCArray::array();
|
||||
m_pDelegates->retain();
|
||||
|
||||
m_pHandlersToAdd = ccCArrayNew(8);
|
||||
m_pHandlersToRemove = ccCArrayNew(8);
|
||||
|
@ -124,12 +125,11 @@ void CCKeypadDispatcher::forceAddDelegate(CCKeypadDelegate* pDelegate)
|
|||
|
||||
void CCKeypadDispatcher::forceRemoveDelegate(CCKeypadDelegate* pDelegate)
|
||||
{
|
||||
CCKeypadHandler *pHandler;
|
||||
CCMutableArray<CCKeypadHandler*>::CCMutableArrayIterator iter;
|
||||
|
||||
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
|
||||
CCKeypadHandler* pHandler = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pDelegates, pObj)
|
||||
{
|
||||
pHandler = *iter;
|
||||
pHandler = (CCKeypadHandler*)pObj;
|
||||
if (pHandler && pHandler->getDelegate() == pDelegate)
|
||||
{
|
||||
m_pDelegates->removeObject(pHandler);
|
||||
|
@ -140,19 +140,19 @@ void CCKeypadDispatcher::forceRemoveDelegate(CCKeypadDelegate* pDelegate)
|
|||
|
||||
bool CCKeypadDispatcher::dispatchKeypadMSG(ccKeypadMSGType nMsgType)
|
||||
{
|
||||
CCKeypadHandler *pHandler;
|
||||
CCKeypadDelegate *pDelegate;
|
||||
CCMutableArray<CCKeypadHandler*>::CCMutableArrayIterator iter;
|
||||
CCKeypadHandler* pHandler = NULL;
|
||||
CCKeypadDelegate* pDelegate = NULL;
|
||||
|
||||
m_bLocked = true;
|
||||
|
||||
if (m_pDelegates->count() > 0)
|
||||
{
|
||||
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pDelegates, pObj)
|
||||
{
|
||||
CC_BREAK_IF(!(*iter));
|
||||
CC_BREAK_IF(!pObj);
|
||||
|
||||
pHandler = *iter;
|
||||
pHandler = (CCKeypadHandler*)pObj;
|
||||
pDelegate = pHandler->getDelegate();
|
||||
|
||||
switch (nMsgType)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -745,7 +745,8 @@ void CCLayerMultiplex::addLayer(CCLayer* layer)
|
|||
|
||||
bool CCLayerMultiplex::initWithLayer(CCLayer* layer)
|
||||
{
|
||||
m_pLayers = new CCMutableArray<CCLayer*>(1);
|
||||
m_pLayers = CCArray::array();
|
||||
m_pLayers->retain();
|
||||
m_pLayers->addObject(layer);
|
||||
m_nEnabledLayer = 0;
|
||||
this->addChild(layer);
|
||||
|
@ -754,8 +755,8 @@ bool CCLayerMultiplex::initWithLayer(CCLayer* layer)
|
|||
|
||||
bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params)
|
||||
{
|
||||
m_pLayers = new CCMutableArray<CCLayer*>(5);
|
||||
//m_pLayers->retain();
|
||||
m_pLayers = CCArray::arrayWithCapacity(5);
|
||||
m_pLayers->retain();
|
||||
|
||||
m_pLayers->addObject(layer);
|
||||
|
||||
|
@ -766,7 +767,7 @@ bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params)
|
|||
}
|
||||
|
||||
m_nEnabledLayer = 0;
|
||||
this->addChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer));
|
||||
this->addChild((CCNode*)m_pLayers->objectAtIndex(m_nEnabledLayer));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -776,24 +777,24 @@ void CCLayerMultiplex::switchTo(unsigned int n)
|
|||
{
|
||||
CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
||||
|
||||
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
||||
this->removeChild((CCNode*)m_pLayers->objectAtIndex(m_nEnabledLayer), true);
|
||||
|
||||
m_nEnabledLayer = n;
|
||||
|
||||
this->addChild(m_pLayers->getObjectAtIndex(n));
|
||||
this->addChild((CCNode*)m_pLayers->objectAtIndex(n));
|
||||
}
|
||||
|
||||
void CCLayerMultiplex::switchToAndReleaseMe(unsigned int n)
|
||||
{
|
||||
CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
||||
|
||||
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
||||
this->removeChild((CCNode*)m_pLayers->objectAtIndex(m_nEnabledLayer), true);
|
||||
|
||||
//[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]];
|
||||
m_pLayers->replaceObjectAtIndex(m_nEnabledLayer, NULL);
|
||||
|
||||
m_nEnabledLayer = n;
|
||||
|
||||
this->addChild(m_pLayers->getObjectAtIndex(n));
|
||||
this->addChild((CCNode*)m_pLayers->objectAtIndex(n));
|
||||
}
|
||||
}//namespace cocos2d
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -150,7 +150,7 @@ bool CCParticleSystem::initWithFile(const char *plistFile)
|
|||
{
|
||||
bool bRet = false;
|
||||
m_sPlistFile = CCFileUtils::fullPathFromRelativePath(plistFile);
|
||||
CCDictionary<std::string, CCObject*> *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str());
|
||||
CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str());
|
||||
|
||||
CCAssert( dict != NULL, "Particles: file not found");
|
||||
bRet = this->initWithDictionary(dict);
|
||||
|
@ -159,7 +159,7 @@ bool CCParticleSystem::initWithFile(const char *plistFile)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *dictionary)
|
||||
bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned char *buffer = NULL;
|
||||
|
|
|
@ -52,14 +52,14 @@ typedef enum
|
|||
class CCDictMaker : public CCSAXDelegator
|
||||
{
|
||||
public:
|
||||
CCDictionary<std::string, CCObject*> *m_pRootDict;
|
||||
CCDictionary<std::string, CCObject*> *m_pCurDict;
|
||||
std::stack<CCDictionary<std::string, CCObject*>*> m_tDictStack;
|
||||
CCDictionary *m_pRootDict;
|
||||
CCDictionary *m_pCurDict;
|
||||
std::stack<CCDictionary*> m_tDictStack;
|
||||
std::string m_sCurKey;///< parsed key
|
||||
CCSAXState m_tState;
|
||||
CCMutableArray<CCObject*> *m_pArray;
|
||||
CCArray* m_pArray;
|
||||
|
||||
std::stack<CCMutableArray<CCObject*>*> m_tArrayStack;
|
||||
std::stack<CCArray*> m_tArrayStack;
|
||||
std::stack<CCSAXState> m_tStateStack;
|
||||
|
||||
public:
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFile(const char *pFileName)
|
||||
CCDictionary* dictionaryWithContentsOfFile(const char *pFileName)
|
||||
{
|
||||
CCSAXParser parser;
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
std::string sName((char*)name);
|
||||
if( sName == "dict" )
|
||||
{
|
||||
m_pCurDict = new CCDictionary<std::string, CCObject*>();
|
||||
m_pCurDict = new CCDictionary();
|
||||
if(! m_pRootDict)
|
||||
{
|
||||
// Because it will call m_pCurDict->release() later, so retain here.
|
||||
|
@ -120,8 +120,8 @@ public:
|
|||
{
|
||||
// add the dictionary into the pre dictionary
|
||||
CCAssert(! m_tDictStack.empty(), "The state is wrong!");
|
||||
CCDictionary<std::string, CCObject*>* pPreDict = m_tDictStack.top();
|
||||
pPreDict->setObject(m_pCurDict, m_sCurKey);
|
||||
CCDictionary* pPreDict = m_tDictStack.top();
|
||||
pPreDict->setObject(m_pCurDict, m_sCurKey.c_str());
|
||||
}
|
||||
|
||||
m_pCurDict->release();
|
||||
|
@ -149,17 +149,18 @@ public:
|
|||
else if (sName == "array")
|
||||
{
|
||||
m_tState = SAX_ARRAY;
|
||||
m_pArray = new CCMutableArray<CCObject*>();
|
||||
m_pArray = CCArray::array();
|
||||
m_pArray->retain();
|
||||
|
||||
CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
|
||||
if (preState == SAX_DICT)
|
||||
{
|
||||
m_pCurDict->setObject(m_pArray, m_sCurKey);
|
||||
m_pCurDict->setObject(m_pArray, m_sCurKey.c_str());
|
||||
}
|
||||
else if (preState == SAX_ARRAY)
|
||||
{
|
||||
CCAssert(! m_tArrayStack.empty(), "The state is worng!");
|
||||
CCMutableArray<CCObject*>* pPreArray = m_tArrayStack.top();
|
||||
CCArray* pPreArray = m_tArrayStack.top();
|
||||
pPreArray->addObject(m_pArray);
|
||||
}
|
||||
m_pArray->release();
|
||||
|
@ -205,7 +206,7 @@ public:
|
|||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
m_pCurDict->setObject(str, m_sCurKey);
|
||||
m_pCurDict->setObject(str, m_sCurKey.c_str());
|
||||
}
|
||||
str->release();
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ public:
|
|||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
m_pCurDict->setObject(str, m_sCurKey);
|
||||
m_pCurDict->setObject(str, m_sCurKey.c_str());
|
||||
}
|
||||
str->release();
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ public:
|
|||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
m_pCurDict->setObject(pText, m_sCurKey);
|
||||
m_pCurDict->setObject(pText, m_sCurKey.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -287,15 +288,15 @@ std::string& CCFileUtils::ccRemoveHDSuffixFromFile(std::string& path)
|
|||
return path;
|
||||
}
|
||||
|
||||
CCDictionary<std::string, CCObject*> *CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
|
||||
CCDictionary* CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
|
||||
{
|
||||
CCDictionary<std::string, CCObject*> *ret = dictionaryWithContentsOfFileThreadSafe(pFileName);
|
||||
CCDictionary* ret = dictionaryWithContentsOfFileThreadSafe(pFileName);
|
||||
ret->autorelease();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCDictionary<std::string, CCObject*> *CCFileUtils::dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
|
||||
CCDictionary* CCFileUtils::dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
|
||||
{
|
||||
CCDictMaker tMaker;
|
||||
return tMaker.dictionaryWithContentsOfFile(pFileName);
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
#define __CC_FILEUTILS_PLATFORM_H__
|
||||
|
||||
#include <string>
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
|
@ -87,13 +87,13 @@ public:
|
|||
@param pFileName The file name of *.plist file
|
||||
@return The CCDictionary pointer generated from the file
|
||||
*/
|
||||
static CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFile(const char *pFileName);
|
||||
static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName);
|
||||
|
||||
/*
|
||||
@brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the
|
||||
invoker should call release().
|
||||
*/
|
||||
static CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFileThreadSafe(const char *pFileName);
|
||||
static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName);
|
||||
|
||||
/**
|
||||
@brief Get the writeable path
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCSAXParser.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
|
|
@ -211,6 +211,10 @@
|
|||
RelativePath="..\cocoa\CCData.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cocoa\CCDictionary.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cocoa\CCGeometry.cpp"
|
||||
>
|
||||
|
@ -399,6 +403,10 @@
|
|||
RelativePath="..\include\CCData.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCDictionary.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCDirector.h"
|
||||
>
|
||||
|
@ -435,6 +443,10 @@
|
|||
RelativePath="..\include\CCIMEDispatcher.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCInteger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCKeypadDelegate.h"
|
||||
>
|
||||
|
@ -1100,22 +1112,6 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="gles2"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\gles2\CCGLProgram.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gles2\ccGLStateCache.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gles2\CCShaderCache.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="kazmath"
|
||||
>
|
||||
|
@ -1251,6 +1247,18 @@
|
|||
<Filter
|
||||
Name="shaders"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\shaders\CCGLProgram.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shaders\ccGLStateCache.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shaders\CCShaderCache.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shaders\ccShaders.cpp"
|
||||
>
|
||||
|
|
|
@ -64,7 +64,7 @@ CCShaderCache::~CCShaderCache()
|
|||
|
||||
bool CCShaderCache::init()
|
||||
{
|
||||
m_pPrograms = new CCMutableDictionary<std::string, CCGLProgram*>();
|
||||
m_pPrograms = new CCDictionary();
|
||||
loadDefaultShaders();
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ void CCShaderCache::loadDefaultShaders()
|
|||
|
||||
CCGLProgram* CCShaderCache::programForKey(const char* key)
|
||||
{
|
||||
return m_pPrograms->objectForKey(key);
|
||||
return (CCGLProgram*)m_pPrograms->objectForKey(key);
|
||||
}
|
||||
|
||||
void CCShaderCache::addProgram(CCGLProgram* program, const char* key)
|
|
@ -40,7 +40,7 @@ CCAnimationFrame::CCAnimationFrame()
|
|||
|
||||
}
|
||||
|
||||
bool CCAnimationFrame::initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCObjectDictionary* userInfo)
|
||||
bool CCAnimationFrame::initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo)
|
||||
{
|
||||
setSpriteFrame(spriteFrame);
|
||||
setDelayUnits(delayUnits);
|
||||
|
@ -73,7 +73,7 @@ CCObject* CCAnimationFrame::copyWithZone(CCZone* pZone)
|
|||
}
|
||||
|
||||
pCopy->initWithSpriteFrame((CCSpriteFrame*)m_pSpriteFrame->copy()->autorelease(),
|
||||
m_fDelayUnits, (CCObjectDictionary*)m_pUserInfo->copy()->autorelease());
|
||||
m_fDelayUnits, m_pUserInfo != NULL ? (CCDictionary*)m_pUserInfo->copy()->autorelease() : NULL);
|
||||
|
||||
CC_SAFE_DELETE(pNewZone);
|
||||
return pCopy;
|
||||
|
@ -90,7 +90,7 @@ CCAnimation* CCAnimation::animation(void)
|
|||
return pAnimation;
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::animationWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *frames)
|
||||
CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames)
|
||||
{
|
||||
CCAnimation *pAnimation = new CCAnimation();
|
||||
pAnimation->initWithSpriteFrames(frames);
|
||||
|
@ -99,7 +99,7 @@ CCAnimation* CCAnimation::animationWithSpriteFrames(CCMutableArray<CCSpriteFrame
|
|||
return pAnimation;
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::animationWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *frames, float delay)
|
||||
CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay)
|
||||
{
|
||||
CCAnimation *pAnimation = new CCAnimation();
|
||||
pAnimation->initWithSpriteFrames(frames, delay);
|
||||
|
@ -108,7 +108,7 @@ CCAnimation* CCAnimation::animationWithSpriteFrames(CCMutableArray<CCSpriteFrame
|
|||
return pAnimation;
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::animationWithAnimationFrames(CCMutableArray<CCAnimationFrame*>* arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops)
|
||||
CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops)
|
||||
{
|
||||
CCAnimation *pAnimation = new CCAnimation();
|
||||
pAnimation->initWithAnimationFrames(arrayOfSpriteFrameNames, delayPerUnit, loops);
|
||||
|
@ -121,24 +121,26 @@ bool CCAnimation::init()
|
|||
return initWithSpriteFrames(NULL, 0.0f);
|
||||
}
|
||||
|
||||
bool CCAnimation::initWithSpriteFrames(CCMutableArray<CCSpriteFrame*>* pFrames)
|
||||
bool CCAnimation::initWithSpriteFrames(CCArray* pFrames)
|
||||
{
|
||||
return initWithSpriteFrames(pFrames, 0.0f);
|
||||
}
|
||||
|
||||
bool CCAnimation::initWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay)
|
||||
bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay)
|
||||
{
|
||||
CCARRAY_VERIFY_TYPE(pFrames, CCSpriteFrame*);
|
||||
|
||||
m_uLoops = 1;
|
||||
m_fDelayPerUnit = delay;
|
||||
CCMutableArray<CCAnimationFrame*>* pTmpFrames = new CCMutableArray<CCAnimationFrame*>();
|
||||
pTmpFrames->autorelease();
|
||||
CCArray* pTmpFrames = CCArray::array();
|
||||
setFrames(pTmpFrames);
|
||||
|
||||
if (pFrames != NULL)
|
||||
{
|
||||
for(CCMutableArray<CCSpriteFrame*>::CCMutableArrayIterator it = pFrames->begin(); it != pFrames->end(); ++it)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(pFrames, pObj)
|
||||
{
|
||||
CCSpriteFrame* frame = *it;
|
||||
CCSpriteFrame* frame = (CCSpriteFrame*)pObj;
|
||||
CCAnimationFrame *animFrame = new CCAnimationFrame();
|
||||
animFrame->initWithSpriteFrame(frame, 1, NULL);
|
||||
m_pFrames->addObject(animFrame);
|
||||
|
@ -151,16 +153,19 @@ bool CCAnimation::initWithSpriteFrames(CCMutableArray<CCSpriteFrame*> *pFrames,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CCAnimation::initWithAnimationFrames(CCMutableArray<CCAnimationFrame*>* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops)
|
||||
bool CCAnimation::initWithAnimationFrames(CCArray* arrayOfAnimationFrames, float delayPerUnit, unsigned int loops)
|
||||
{
|
||||
CCARRAY_VERIFY_TYPE(arrayOfAnimationFrames, CCAnimationFrame*);
|
||||
|
||||
m_fDelayPerUnit = delayPerUnit;
|
||||
m_uLoops = loops;
|
||||
|
||||
setFrames(CCMutableArray<CCAnimationFrame*>::arrayWithArray(arrayOfAnimationFrames));
|
||||
setFrames(CCArray::arrayWithArray(arrayOfAnimationFrames));
|
||||
|
||||
for( CCMutableArray<CCAnimationFrame*>::CCMutableArrayIterator it = m_pFrames->begin(); it != m_pFrames->end(); ++it )
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pFrames, pObj)
|
||||
{
|
||||
CCAnimationFrame *animFrame = *it;
|
||||
CCAnimationFrame* animFrame = (CCAnimationFrame*)pObj;
|
||||
m_fTotalDelayUnits += animFrame->getDelayUnits();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,7 @@ void CCAnimationCache::purgeSharedAnimationCache(void)
|
|||
|
||||
bool CCAnimationCache::init()
|
||||
{
|
||||
m_pAnimations = new CCMutableDictionary<std::string, CCAnimation*>();
|
||||
m_pAnimations = new CCDictionary();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ CCAnimationCache::~CCAnimationCache()
|
|||
|
||||
void CCAnimationCache::addAnimation(CCAnimation *animation, const char * name)
|
||||
{
|
||||
m_pAnimations->setObject(animation, std::string(name));
|
||||
m_pAnimations->setObject(animation, name);
|
||||
}
|
||||
|
||||
void CCAnimationCache::removeAnimationByName(const char* name)
|
||||
|
@ -81,41 +81,43 @@ void CCAnimationCache::removeAnimationByName(const char* name)
|
|||
return;
|
||||
}
|
||||
|
||||
m_pAnimations->removeObjectForKey(std::string(name));
|
||||
m_pAnimations->removeObjectForKey(name);
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimationCache::animationByName(const char* name)
|
||||
{
|
||||
return m_pAnimations->objectForKey(std::string(name));
|
||||
return (CCAnimation*)m_pAnimations->objectForKey(name);
|
||||
}
|
||||
|
||||
void CCAnimationCache::parseVersion1(CCObjectDictionary* animations)
|
||||
void CCAnimationCache::parseVersion1(CCDictionary* animations)
|
||||
{
|
||||
vector<std::string> animationNames = animations->allKeys();
|
||||
CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
|
||||
|
||||
for (vector<std::string>::iterator iterName = animationNames.begin(); iterName != animationNames.end(); ++iterName)
|
||||
{
|
||||
string name = *iterName;
|
||||
CCObjectDictionary* animationDict = (CCObjectDictionary*)animations->objectForKey(name);
|
||||
CCMutableArray<CCObject*>* frameNames = (CCMutableArray<CCObject*>*)animationDict->objectForKey("frames");
|
||||
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
{
|
||||
CCDictionary* animationDict = (CCDictionary*)pElement->getObject();
|
||||
CCArray* frameNames = (CCArray*)animationDict->objectForKey("frames");
|
||||
float delay = (float)atof(valueForKey("delay", animationDict));
|
||||
CCAnimation* animation = NULL;
|
||||
|
||||
if ( frameNames == NULL ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name.c_str());
|
||||
if ( frameNames == NULL )
|
||||
{
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
CCMutableArray<CCAnimationFrame*>* frames = new CCMutableArray<CCAnimationFrame*>(frameNames->count());
|
||||
CCArray* frames = CCArray::arrayWithCapacity(frameNames->count());
|
||||
frames->retain();
|
||||
|
||||
for (CCMutableArray<CCObject*>::CCMutableArrayIterator iterFrameName = frameNames->begin(); iterFrameName != frameNames->end(); ++iterFrameName)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(frameNames, pObj)
|
||||
{
|
||||
const char* frameName = ((CCString*)(*iterFrameName))->toStdString().c_str();
|
||||
const char* frameName = ((CCString*)pObj)->c_str();
|
||||
CCSpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);
|
||||
|
||||
if ( ! spriteFrame ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name.c_str(), frameName);
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -127,57 +129,59 @@ void CCAnimationCache::parseVersion1(CCObjectDictionary* animations)
|
|||
}
|
||||
|
||||
if ( frames->count() == 0 ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: None of the frames for animation '%s' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", name.c_str());
|
||||
CCLOG("cocos2d: CCAnimationCache: None of the frames for animation '%s' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
|
||||
continue;
|
||||
} else if ( frames->count() != frameNames->count() ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", name.c_str());
|
||||
CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
|
||||
}
|
||||
|
||||
animation = CCAnimation::animationWithAnimationFrames(frames, delay, 1);
|
||||
|
||||
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, name.c_str());
|
||||
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
|
||||
frames->release();
|
||||
}
|
||||
}
|
||||
|
||||
void CCAnimationCache::parseVersion2(CCObjectDictionary* animations)
|
||||
void CCAnimationCache::parseVersion2(CCDictionary* animations)
|
||||
{
|
||||
vector<std::string> animationNames = animations->allKeys();
|
||||
CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
|
||||
|
||||
for (vector<std::string>::iterator iterName = animationNames.begin(); iterName != animationNames.end(); ++iterName)
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
{
|
||||
string name = *iterName;
|
||||
CCObjectDictionary* animationDict = (CCObjectDictionary*)animations->objectForKey(name);
|
||||
const char* name = pElement->getStrKey();
|
||||
CCDictionary* animationDict = (CCDictionary*)pElement->getObject();
|
||||
|
||||
int loops = atoi(valueForKey("loops", animationDict));
|
||||
bool restoreOriginalFrame = atoi(valueForKey("restoreOriginalFrame", animationDict)) == 0 ? false : true;
|
||||
|
||||
CCMutableArray<CCObject*>* frameArray = (CCMutableArray<CCObject*>*)animationDict->objectForKey("frames");
|
||||
CCArray* frameArray = (CCArray*)animationDict->objectForKey("frames");
|
||||
|
||||
if ( frameArray == NULL ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name.c_str());
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Array of AnimationFrames
|
||||
CCMutableArray<CCAnimationFrame*>* array = new CCMutableArray<CCAnimationFrame*>(frameArray->count());
|
||||
CCArray* array = CCArray::arrayWithCapacity(frameArray->count());
|
||||
array->retain();
|
||||
|
||||
for (CCMutableArray<CCObject*>::CCMutableArrayIterator iterFrameName = frameArray->begin(); iterFrameName != frameArray->end(); ++iterFrameName)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(frameArray, pObj)
|
||||
{
|
||||
CCObjectDictionary* entry = (CCObjectDictionary*)(*iterFrameName);
|
||||
CCDictionary* entry = (CCDictionary*)(pObj);
|
||||
|
||||
const char* spriteFrameName = valueForKey("spriteframe", entry);
|
||||
CCSpriteFrame *spriteFrame = frameCache->spriteFrameByName(spriteFrameName);
|
||||
|
||||
if( ! spriteFrame ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name.c_str(), spriteFrameName);
|
||||
CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name, spriteFrameName);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
float delayUnits = (float)atof(valueForKey("delayUnits", entry));
|
||||
CCObjectDictionary* userInfo = (CCObjectDictionary*)entry->objectForKey("notification");
|
||||
CCDictionary* userInfo = (CCDictionary*)entry->objectForKey("notification");
|
||||
|
||||
CCAnimationFrame *animFrame = new CCAnimationFrame();
|
||||
animFrame->initWithSpriteFrame(spriteFrame, delayUnits, userInfo);
|
||||
|
@ -193,14 +197,14 @@ void CCAnimationCache::parseVersion2(CCObjectDictionary* animations)
|
|||
|
||||
animation->setRestoreOriginalFrame(restoreOriginalFrame);
|
||||
|
||||
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, name.c_str());
|
||||
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, name);
|
||||
animation->release();
|
||||
}
|
||||
}
|
||||
|
||||
void CCAnimationCache::addAnimationsWithDictionary(CCObjectDictionary* dictionary)
|
||||
void CCAnimationCache::addAnimationsWithDictionary(CCDictionary* dictionary)
|
||||
{
|
||||
CCObjectDictionary* animations = (CCObjectDictionary*)dictionary->objectForKey("animations");
|
||||
CCDictionary* animations = (CCDictionary*)dictionary->objectForKey("animations");
|
||||
|
||||
if ( animations == NULL ) {
|
||||
CCLOG("cocos2d: CCAnimationCache: No animations were found in provided dictionary.");
|
||||
|
@ -208,18 +212,19 @@ void CCAnimationCache::addAnimationsWithDictionary(CCObjectDictionary* dictionar
|
|||
}
|
||||
|
||||
unsigned int version = 1;
|
||||
CCObjectDictionary* properties = (CCObjectDictionary*)dictionary->objectForKey("properties");
|
||||
CCDictionary* properties = (CCDictionary*)dictionary->objectForKey("properties");
|
||||
if( properties )
|
||||
{
|
||||
version = atoi(valueForKey("format", properties));
|
||||
}
|
||||
|
||||
CCMutableArray<CCObject*>* spritesheets = (CCMutableArray<CCObject*>*)properties->objectForKey("spritesheets");
|
||||
CCArray* spritesheets = (CCArray*)properties->objectForKey("spritesheets");
|
||||
|
||||
for( CCMutableArray<CCObject*>::CCMutableArrayIterator iterName = spritesheets->begin(); iterName != spritesheets->end(); ++iterName)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(spritesheets, pObj)
|
||||
{
|
||||
CCString* name = (CCString*)(*iterName);
|
||||
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(name->toStdString().c_str());
|
||||
CCString* name = (CCString*)(pObj);
|
||||
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(name->c_str());
|
||||
}
|
||||
|
||||
switch (version) {
|
||||
|
@ -234,11 +239,11 @@ void CCAnimationCache::addAnimationsWithDictionary(CCObjectDictionary* dictionar
|
|||
}
|
||||
}
|
||||
|
||||
const char * CCAnimationCache::valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict)
|
||||
const char * CCAnimationCache::valueForKey(const char *key, CCDictionary *dict)
|
||||
{
|
||||
if (dict)
|
||||
{
|
||||
CCString *pString = (CCString*)dict->objectForKey(std::string(key));
|
||||
CCString *pString = (CCString*)dict->objectForKey(key);
|
||||
return pString ? pString->m_sString.c_str() : "";
|
||||
}
|
||||
return "";
|
||||
|
@ -250,7 +255,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist)
|
|||
CCAssert( plist, "Invalid texture file name");
|
||||
|
||||
const char* path = CCFileUtils::fullPathFromRelativePath(plist);
|
||||
CCObjectDictionary* dict = CCFileUtils::dictionaryWithContentsOfFile(path);
|
||||
CCDictionary* dict = CCFileUtils::dictionaryWithContentsOfFile(path);
|
||||
|
||||
CCAssert( dict, "CCAnimationCache: File could not be found");
|
||||
|
||||
|
|
|
@ -960,7 +960,7 @@ void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int f
|
|||
|
||||
CCAssert(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found");
|
||||
|
||||
CCAnimationFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex);
|
||||
CCAnimationFrame* frame = (CCAnimationFrame*)a->getFrames()->objectAtIndex(frameIndex);
|
||||
|
||||
CCAssert(frame, "CCSprite#setDisplayFrame. Invalid frame");
|
||||
|
||||
|
|
|
@ -35,8 +35,12 @@ THE SOFTWARE.
|
|||
#include "support/TransformUtils.h"
|
||||
#include "CCFileUtils.h"
|
||||
#include "CCString.h"
|
||||
#include "CCArray.h"
|
||||
#include <vector>
|
||||
|
||||
namespace cocos2d {
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
static CCSpriteFrameCache *pSharedSpriteFrameCache = NULL;
|
||||
|
||||
|
@ -58,8 +62,8 @@ void CCSpriteFrameCache::purgeSharedSpriteFrameCache(void)
|
|||
|
||||
bool CCSpriteFrameCache::init(void)
|
||||
{
|
||||
m_pSpriteFrames= new CCDictionary<std::string, CCSpriteFrame*>();
|
||||
m_pSpriteFramesAliases = new CCDictionary<std::string, CCString*>();
|
||||
m_pSpriteFrames= new CCDictionary();
|
||||
m_pSpriteFramesAliases = new CCDictionary();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,7 +73,7 @@ CCSpriteFrameCache::~CCSpriteFrameCache(void)
|
|||
CC_SAFE_RELEASE(m_pSpriteFramesAliases);
|
||||
}
|
||||
|
||||
void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string, CCObject*> *dictionary, CCTexture2D *pobTexture)
|
||||
void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, CCTexture2D *pobTexture)
|
||||
{
|
||||
/*
|
||||
Supported Zwoptex Formats:
|
||||
|
@ -80,8 +84,8 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
|
|||
ZWTCoordinatesFormatOptionXML1_2 = 3, // Desktop Version 1.0.2+
|
||||
*/
|
||||
|
||||
CCDictionary<std::string, CCObject*> *metadataDict = (CCDictionary<std::string, CCObject*>*)dictionary->objectForKey(std::string("metadata"));
|
||||
CCDictionary<std::string, CCObject*> *framesDict = (CCDictionary<std::string, CCObject*>*)dictionary->objectForKey(std::string("frames"));
|
||||
CCDictionary *metadataDict = (CCDictionary*)dictionary->objectForKey("metadata");
|
||||
CCDictionary *framesDict = (CCDictionary*)dictionary->objectForKey("frames");
|
||||
int format = 0;
|
||||
|
||||
// get the format
|
||||
|
@ -93,12 +97,11 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
|
|||
// check the format
|
||||
CCAssert(format >=0 && format <= 3, "");
|
||||
|
||||
framesDict->begin();
|
||||
std::string key = "";
|
||||
CCDictionary<std::string, CCObject*> *frameDict = NULL;
|
||||
while( (frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key)) )
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
{
|
||||
CCSpriteFrame *spriteFrame = m_pSpriteFrames->objectForKey(key);
|
||||
CCDictionary* frameDict = (CCDictionary*)pElement->getObject();
|
||||
CCSpriteFrame* spriteFrame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(pElement->getStrKey());
|
||||
if (spriteFrame)
|
||||
{
|
||||
continue;
|
||||
|
@ -164,19 +167,19 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
|
|||
bool textureRotated = atoi(valueForKey("textureRotated", frameDict)) == 0 ? false : true;
|
||||
|
||||
// get aliases
|
||||
CCMutableArray<CCString*> *aliases = (CCMutableArray<CCString*> *) (frameDict->objectForKey(std::string("aliases")));
|
||||
CCMutableArray<CCString*>::CCMutableArrayIterator iter;
|
||||
CCArray* aliases = (CCArray*) (frameDict->objectForKey("aliases"));
|
||||
CCString * frameKey = new CCString(pElement->getStrKey());
|
||||
|
||||
CCString * frameKey = new CCString(key.c_str());
|
||||
for (iter = aliases->begin(); iter != aliases->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(aliases, pObj)
|
||||
{
|
||||
std::string oneAlias = ((CCString*) (*iter))->m_sString;
|
||||
if (m_pSpriteFramesAliases->objectForKey(oneAlias))
|
||||
std::string oneAlias = ((CCString*)pObj)->m_sString;
|
||||
if (m_pSpriteFramesAliases->objectForKey(oneAlias.c_str()))
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str());
|
||||
}
|
||||
|
||||
m_pSpriteFramesAliases->setObject(frameKey, oneAlias);
|
||||
m_pSpriteFramesAliases->setObject(frameKey, oneAlias.c_str());
|
||||
}
|
||||
frameKey->release();
|
||||
// create frame
|
||||
|
@ -189,7 +192,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
|
|||
}
|
||||
|
||||
// add sprite frame
|
||||
m_pSpriteFrames->setObject(spriteFrame, key);
|
||||
m_pSpriteFrames->setObject(spriteFrame, pElement->getStrKey());
|
||||
spriteFrame->release();
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
|
|||
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture)
|
||||
{
|
||||
const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist);
|
||||
CCDictionary<std::string, CCObject*> *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(pszPath);
|
||||
CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(pszPath);
|
||||
|
||||
addSpriteFramesWithDictionary(dict, pobTexture);
|
||||
|
||||
|
@ -222,11 +225,11 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char*
|
|||
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
||||
{
|
||||
const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist);
|
||||
CCDictionary<std::string, CCObject*> *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(pszPath);
|
||||
CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(pszPath);
|
||||
|
||||
string texturePath("");
|
||||
|
||||
CCDictionary<std::string, CCObject*>* metadataDict = (CCDictionary<std::string, CCObject*>*)dict->objectForKey(string("metadata"));
|
||||
CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata");
|
||||
if (metadataDict)
|
||||
{
|
||||
// try to read texture file name from meta data
|
||||
|
@ -269,7 +272,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
|||
|
||||
void CCSpriteFrameCache::addSpriteFrame(CCSpriteFrame *pobFrame, const char *pszFrameName)
|
||||
{
|
||||
m_pSpriteFrames->setObject(pobFrame, std::string(pszFrameName));
|
||||
m_pSpriteFrames->setObject(pobFrame, pszFrameName);
|
||||
}
|
||||
|
||||
void CCSpriteFrameCache::removeSpriteFrames(void)
|
||||
|
@ -280,18 +283,16 @@ void CCSpriteFrameCache::removeSpriteFrames(void)
|
|||
|
||||
void CCSpriteFrameCache::removeUnusedSpriteFrames(void)
|
||||
{
|
||||
m_pSpriteFrames->begin();
|
||||
std::string key = "";
|
||||
CCSpriteFrame *spriteFrame = NULL;
|
||||
while( (spriteFrame = m_pSpriteFrames->next(&key)) )
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pSpriteFrames, pElement)
|
||||
{
|
||||
CCSpriteFrame* spriteFrame = (CCSpriteFrame*)pElement->getObject();
|
||||
if( spriteFrame->retainCount() == 1 )
|
||||
{
|
||||
CCLOG("cocos2d: CCSpriteFrameCache: removing unused frame: %s", key.c_str());
|
||||
m_pSpriteFrames->removeObjectForKey(key);
|
||||
CCLOG("cocos2d: CCSpriteFrameCache: removing unused frame: %s", pElement->getStrKey());
|
||||
m_pSpriteFrames->removeObjectForKey(pElement->getStrKey());
|
||||
}
|
||||
}
|
||||
m_pSpriteFrames->end();
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,50 +305,47 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName)
|
|||
}
|
||||
|
||||
// Is this an alias ?
|
||||
CCString *key = (CCString*)m_pSpriteFramesAliases->objectForKey(string(pszName));
|
||||
CCString *key = (CCString*)m_pSpriteFramesAliases->objectForKey(pszName);
|
||||
|
||||
if (key)
|
||||
{
|
||||
m_pSpriteFrames->removeObjectForKey(key->m_sString);
|
||||
m_pSpriteFramesAliases->removeObjectForKey(key->m_sString);
|
||||
m_pSpriteFrames->removeObjectForKey(key->c_str());
|
||||
m_pSpriteFramesAliases->removeObjectForKey(key->c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpriteFrames->removeObjectForKey(std::string(pszName));
|
||||
m_pSpriteFrames->removeObjectForKey(pszName);
|
||||
}
|
||||
}
|
||||
|
||||
void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
|
||||
{
|
||||
const char* path = CCFileUtils::fullPathFromRelativePath(plist);
|
||||
CCDictionary<std::string, CCObject*>* dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(path);
|
||||
CCDictionary* dict = CCFileUtils::dictionaryWithContentsOfFileThreadSafe(path);
|
||||
|
||||
removeSpriteFramesFromDictionary((CCDictionary<std::string, CCSpriteFrame*>*)dict);
|
||||
removeSpriteFramesFromDictionary((CCDictionary*)dict);
|
||||
|
||||
dict->release();
|
||||
}
|
||||
|
||||
void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary<std::string, CCSpriteFrame*> *dictionary)
|
||||
void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary* dictionary)
|
||||
{
|
||||
CCDictionary<std::string, CCObject*>* framesDict = (CCDictionary<std::string, CCObject*>*)dictionary->objectForKey(string("frames"));
|
||||
CCDictionary* framesDict = (CCDictionary*)dictionary->objectForKey("frames");
|
||||
vector<string> keysToRemove;
|
||||
|
||||
framesDict->begin();
|
||||
std::string key = "";
|
||||
CCDictionary<std::string, CCObject*> *frameDict = NULL;
|
||||
while( (frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key)) )
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
{
|
||||
if (m_pSpriteFrames->objectForKey(key))
|
||||
if (m_pSpriteFrames->objectForKey(pElement->getStrKey()))
|
||||
{
|
||||
keysToRemove.push_back(key);
|
||||
keysToRemove.push_back(pElement->getStrKey());
|
||||
}
|
||||
}
|
||||
framesDict->end();
|
||||
|
||||
vector<string>::iterator iter;
|
||||
for (iter = keysToRemove.begin(); iter != keysToRemove.end(); ++iter)
|
||||
{
|
||||
m_pSpriteFrames->removeObjectForKey(*iter);
|
||||
m_pSpriteFrames->removeObjectForKey((*iter).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,36 +353,34 @@ void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture)
|
|||
{
|
||||
vector<string> keysToRemove;
|
||||
|
||||
m_pSpriteFrames->begin();
|
||||
std::string key = "";
|
||||
CCDictionary<std::string, CCObject*> *frameDict = NULL;
|
||||
while( (frameDict = (CCDictionary<std::string, CCObject*>*)m_pSpriteFrames->next(&key)) )
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pSpriteFrames, pElement)
|
||||
{
|
||||
CCSpriteFrame *frame = m_pSpriteFrames->objectForKey(key);
|
||||
string key = pElement->getStrKey();
|
||||
CCSpriteFrame* frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key.c_str());
|
||||
if (frame && (frame->getTexture() == texture))
|
||||
{
|
||||
keysToRemove.push_back(key);
|
||||
}
|
||||
}
|
||||
m_pSpriteFrames->end();
|
||||
|
||||
vector<string>::iterator iter;
|
||||
for (iter = keysToRemove.begin(); iter != keysToRemove.end(); ++iter)
|
||||
{
|
||||
m_pSpriteFrames->removeObjectForKey(*iter);
|
||||
m_pSpriteFrames->removeObjectForKey((*iter).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
CCSpriteFrame* CCSpriteFrameCache::spriteFrameByName(const char *pszName)
|
||||
{
|
||||
CCSpriteFrame *frame = m_pSpriteFrames->objectForKey(std::string(pszName));
|
||||
if (! frame)
|
||||
CCSpriteFrame* frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(pszName);
|
||||
if (!frame)
|
||||
{
|
||||
// try alias dictionary
|
||||
CCString *key = (CCString*)m_pSpriteFramesAliases->objectForKey(string(pszName));
|
||||
CCString *key = (CCString*)m_pSpriteFramesAliases->objectForKey(pszName);
|
||||
if (key)
|
||||
{
|
||||
frame = m_pSpriteFrames->objectForKey(key->m_sString);
|
||||
frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key->c_str());
|
||||
if (! frame)
|
||||
{
|
||||
CCLOG("cocos2d: CCSpriteFrameCahce: Frame '%s' not found", pszName);
|
||||
|
@ -394,13 +390,14 @@ CCSpriteFrame* CCSpriteFrameCache::spriteFrameByName(const char *pszName)
|
|||
return frame;
|
||||
}
|
||||
|
||||
const char * CCSpriteFrameCache::valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict)
|
||||
const char * CCSpriteFrameCache::valueForKey(const char *key, CCDictionary *dict)
|
||||
{
|
||||
if (dict)
|
||||
{
|
||||
CCString *pString = (CCString*)dict->objectForKey(std::string(key));
|
||||
CCString *pString = (CCString*)dict->objectForKey(key);
|
||||
return pString ? pString->m_sString.c_str() : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}//namespace cocos2d
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -25,8 +25,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCArray.h"
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
NS_CC_BEGIN
|
||||
|
||||
CCArray* CCArray::array()
|
||||
{
|
||||
|
@ -158,20 +157,20 @@ void CCArray::insertObject(CCObject* object, unsigned int index)
|
|||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
}
|
||||
|
||||
void CCArray::removeLastObject()
|
||||
void CCArray::removeLastObject(bool bReleaseObj)
|
||||
{
|
||||
CCAssert(data->num, "no objects added");
|
||||
ccArrayRemoveObjectAtIndex(data, data->num-1);
|
||||
ccArrayRemoveObjectAtIndex(data, data->num-1, bReleaseObj);
|
||||
}
|
||||
|
||||
void CCArray::removeObject(CCObject* object)
|
||||
void CCArray::removeObject(CCObject* object, bool bReleaseObj/* = true*/)
|
||||
{
|
||||
ccArrayRemoveObject(data, object);
|
||||
ccArrayRemoveObject(data, object, bReleaseObj);
|
||||
}
|
||||
|
||||
void CCArray::removeObjectAtIndex(unsigned int index)
|
||||
void CCArray::removeObjectAtIndex(unsigned int index, bool bReleaseObj)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(data, index);
|
||||
ccArrayRemoveObjectAtIndex(data, index, bReleaseObj);
|
||||
}
|
||||
|
||||
void CCArray::removeObjectsInArray(CCArray* otherArray)
|
||||
|
@ -242,4 +241,20 @@ CCArray::~CCArray()
|
|||
ccArrayFree(data);
|
||||
}
|
||||
|
||||
void CCArray::replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject/* = true*/)
|
||||
{
|
||||
if (bReleaseObject && uIndex < data->num && data->arr[uIndex] != NULL)
|
||||
{
|
||||
data->arr[uIndex]->release();
|
||||
}
|
||||
|
||||
data->arr[uIndex] = pObject;
|
||||
|
||||
// add the ref
|
||||
if (pObject)
|
||||
{
|
||||
pObject->retain();
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -71,7 +71,7 @@ void CCProfiler::releaseAllTimers()
|
|||
|
||||
bool CCProfiler::init()
|
||||
{
|
||||
m_pActiveTimers = new CCMutableDictionary<std::string, CCProfilingTimer*>();
|
||||
m_pActiveTimers = new CCDictionary();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,10 @@ CCProfiler::~CCProfiler(void)
|
|||
|
||||
void CCProfiler::displayTimers()
|
||||
{
|
||||
vector<string> allKeys = m_pActiveTimers->allKeys();
|
||||
for (vector<string>::iterator it = allKeys.begin(); it != allKeys.end(); ++it)
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pActiveTimers, pElement)
|
||||
{
|
||||
CCProfilingTimer* timer = m_pActiveTimers->objectForKey(*it);
|
||||
CCProfilingTimer* timer = (CCProfilingTimer*)pElement->getObject();
|
||||
CCLog(timer->description());
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ void CCProfilingTimer::reset()
|
|||
void CCProfilingBeginTimingBlock(const char *timerName)
|
||||
{
|
||||
CCProfiler* p = CCProfiler::sharedProfiler();
|
||||
CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName);
|
||||
CCProfilingTimer* timer = (CCProfilingTimer*)p->m_pActiveTimers->objectForKey(timerName);
|
||||
if( ! timer )
|
||||
{
|
||||
timer = p->createAndAddTimerWithName(timerName);
|
||||
|
@ -144,7 +144,7 @@ void CCProfilingBeginTimingBlock(const char *timerName)
|
|||
void CCProfilingEndTimingBlock(const char *timerName)
|
||||
{
|
||||
CCProfiler* p = CCProfiler::sharedProfiler();
|
||||
CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName);
|
||||
CCProfilingTimer* timer = (CCProfilingTimer*)p->m_pActiveTimers->objectForKey(timerName);
|
||||
|
||||
CCAssert(timer, "CCProfilingTimer not found");
|
||||
|
||||
|
@ -164,7 +164,7 @@ void CCProfilingEndTimingBlock(const char *timerName)
|
|||
void CCProfilingResetTimingBlock(const char *timerName)
|
||||
{
|
||||
CCProfiler* p = CCProfiler::sharedProfiler();
|
||||
CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName);
|
||||
CCProfilingTimer *timer = (CCProfilingTimer*)p->m_pActiveTimers->objectForKey(timerName);
|
||||
|
||||
CCAssert(timer, "CCProfilingTimer not found");
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#include <string>
|
||||
#include "CCObject.h"
|
||||
#include "platform/platform.h"
|
||||
#include "CCMutableDictionary.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
/** releases all timers */
|
||||
void releaseAllTimers();
|
||||
|
||||
CCMutableDictionary<std::string, CCProfilingTimer*>* m_pActiveTimers;
|
||||
CCDictionary* m_pActiveTimers;
|
||||
};
|
||||
|
||||
class CCProfilingTimer : public CCObject
|
||||
|
|
|
@ -45,7 +45,7 @@ THE SOFTWARE.
|
|||
#include "CCObject.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
// Easy integration
|
||||
#define CCARRAYDATA_FOREACH(__array__, __object__) \
|
||||
|
@ -86,9 +86,7 @@ static inline void ccArrayFree(ccArray *arr)
|
|||
|
||||
ccArrayRemoveAllObjects(arr);
|
||||
|
||||
//delete arr->m_pObjectArray;
|
||||
free(arr->arr);
|
||||
|
||||
free(arr);
|
||||
}
|
||||
|
||||
|
@ -225,15 +223,19 @@ static inline void ccArrayRemoveAllObjects(ccArray *arr)
|
|||
|
||||
/** Removes object at specified index and pushes back all subsequent objects.
|
||||
Behaviour undefined if index outside [0, num-1]. */
|
||||
static inline void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index)
|
||||
static inline void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj)
|
||||
{
|
||||
arr->arr[index]->release();
|
||||
if (bReleaseObj)
|
||||
{
|
||||
arr->arr[index]->release();
|
||||
}
|
||||
|
||||
arr->num--;
|
||||
|
||||
unsigned int remaining = arr->num - index;
|
||||
if (remaining > 0)
|
||||
{
|
||||
memmove(&arr->arr[index], &arr->arr[index+1], remaining * sizeof(void*));
|
||||
memmove(&arr->arr[index], &arr->arr[index+1], remaining * sizeof(void*));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,18 +254,20 @@ static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object)
|
|||
{
|
||||
unsigned int index = ccArrayGetIndexOfObject(arr, object);
|
||||
if (index != UINT_MAX)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(arr, index);
|
||||
}
|
||||
}
|
||||
|
||||
/** Searches for the first occurance of object and removes it. If object is not
|
||||
found the function has no effect. */
|
||||
static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object)
|
||||
static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj)
|
||||
{
|
||||
unsigned int index = ccArrayGetIndexOfObject(arr, object);
|
||||
|
||||
if (index != UINT_MAX)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(arr, index);
|
||||
ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,7 +277,7 @@ static inline void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
{
|
||||
for( unsigned int i = 0; i < minusArr->num; i++)
|
||||
{
|
||||
ccArrayRemoveObject(arr, minusArr->arr[i]);
|
||||
ccArrayRemoveObject(arr, minusArr->arr[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +291,7 @@ static inline void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
{
|
||||
if( ccArrayContainsObject(minusArr, arr->arr[i]) )
|
||||
{
|
||||
delete arr->arr[i];
|
||||
arr->arr[i]->release();
|
||||
back++;
|
||||
}
|
||||
else
|
||||
|
@ -496,6 +500,6 @@ static inline void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
|||
arr->num -= back;
|
||||
}
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_ARRAY_H
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
/*
|
||||
Copyright (c) 2003-2010, Troy D. Hanson http://uthash.sourceforge.net
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __SUPPORT_DATA_SUPPORT_UTHASH_H__
|
||||
#define __SUPPORT_DATA_SUPPORT_UTHASH_H__
|
||||
|
|
|
@ -41,8 +41,11 @@ THE SOFTWARE.
|
|||
#include "pthread.h"
|
||||
#include "CCThread.h"
|
||||
#include "semaphore.h"
|
||||
#include "CCString.h"
|
||||
|
||||
namespace cocos2d {
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
typedef struct _AsyncStruct
|
||||
{
|
||||
|
@ -169,7 +172,7 @@ CCTextureCache::CCTextureCache()
|
|||
{
|
||||
CCAssert(g_sharedTextureCache == NULL, "Attempted to allocate a second instance of a singleton.");
|
||||
|
||||
m_pTextures = new CCMutableDictionary<std::string, CCTexture2D*>();
|
||||
m_pTextures = new CCDictionary();
|
||||
}
|
||||
|
||||
CCTextureCache::~CCTextureCache()
|
||||
|
@ -205,7 +208,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
|
|||
CCFileUtils::ccRemoveHDSuffixFromFile(pathKey);
|
||||
|
||||
pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str());
|
||||
texture = m_pTextures->objectForKey(pathKey);
|
||||
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
|
||||
|
||||
std::string fullpath = pathKey;
|
||||
if (texture != NULL)
|
||||
|
@ -326,7 +329,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
|
|||
CCFileUtils::ccRemoveHDSuffixFromFile(pathKey);
|
||||
|
||||
pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str());
|
||||
texture = m_pTextures->objectForKey(pathKey);
|
||||
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
|
||||
|
||||
std::string fullpath = pathKey; // (CCFileUtils::fullPathFromRelativePath(path));
|
||||
if( ! texture )
|
||||
|
@ -362,7 +365,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
|
|||
VolatileTexture::addImageTexture(texture, fullpath.c_str(), CCImage::kFmtJpg);
|
||||
#endif
|
||||
|
||||
m_pTextures->setObject(texture, pathKey);
|
||||
m_pTextures->setObject(texture, pathKey.c_str());
|
||||
// autorelease prevents possible crash in multithreaded environments
|
||||
texture->autorelease();
|
||||
}
|
||||
|
@ -390,7 +393,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
|
|||
VolatileTexture::addImageTexture(texture, fullpath.c_str(), CCImage::kFmtPng);
|
||||
#endif
|
||||
|
||||
m_pTextures->setObject(texture, pathKey);
|
||||
m_pTextures->setObject(texture, pathKey.c_str());
|
||||
// autorelease prevents possible crash in multithreaded environments
|
||||
texture->autorelease();
|
||||
}
|
||||
|
@ -454,7 +457,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
|
|||
// remove possible -HD suffix to prevent caching the same image twice (issue #1040)
|
||||
CCFileUtils::ccRemoveHDSuffixFromFile(key);
|
||||
|
||||
if( (tex = m_pTextures->objectForKey(key)) )
|
||||
if( (tex = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) )
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
|
@ -468,7 +471,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
|
|||
// cache the texture file name
|
||||
VolatileTexture::addImageTexture(tex, fullpath.c_str(), CCImage::kFmtRawData);
|
||||
#endif
|
||||
m_pTextures->setObject(tex, key);
|
||||
m_pTextures->setObject(tex, key.c_str());
|
||||
tex->autorelease();
|
||||
}
|
||||
else
|
||||
|
@ -497,7 +500,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
|
|||
do
|
||||
{
|
||||
// If key is nil, then create a new texture each time
|
||||
if(key && (texture = m_pTextures->objectForKey(forKey)))
|
||||
if(key && (texture = (CCTexture2D *)m_pTextures->objectForKey(forKey.c_str())))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -508,7 +511,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
|
|||
|
||||
if(key && texture)
|
||||
{
|
||||
m_pTextures->setObject(texture, forKey);
|
||||
m_pTextures->setObject(texture, forKey.c_str());
|
||||
texture->autorelease();
|
||||
}
|
||||
else
|
||||
|
@ -530,15 +533,15 @@ void CCTextureCache::removeAllTextures()
|
|||
|
||||
void CCTextureCache::removeUnusedTextures()
|
||||
{
|
||||
std::vector<std::string> keys = m_pTextures->allKeys();
|
||||
std::vector<std::string>::iterator it;
|
||||
for (it = keys.begin(); it != keys.end(); ++it)
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pTextures, pElement)
|
||||
{
|
||||
CCTexture2D *value = m_pTextures->objectForKey(*it);
|
||||
CCLOG("cocos2d: CCTextureCache: texture: %s", pElement->getStrKey());
|
||||
CCTexture2D *value = (CCTexture2D*)pElement->getObject();
|
||||
if (value->retainCount() == 1)
|
||||
{
|
||||
CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", (*it).c_str());
|
||||
m_pTextures->removeObjectForKey(*it);
|
||||
CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", pElement->getStrKey());
|
||||
m_pTextures->removeObjectForKey(pElement->getStrKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -548,11 +551,12 @@ void CCTextureCache::removeTexture(CCTexture2D* texture)
|
|||
if( ! texture )
|
||||
return;
|
||||
|
||||
std::vector<std::string> keys = m_pTextures->allKeysForObject(texture);
|
||||
|
||||
for (unsigned int i = 0; i < keys.size(); i++)
|
||||
CCArray* keys = m_pTextures->allKeysForObject(texture);
|
||||
CCObject* pObj;
|
||||
CCARRAY_FOREACH(keys, pObj)
|
||||
{
|
||||
m_pTextures->removeObjectForKey(keys[i]);
|
||||
CCString* pKey = (CCString*)pObj;
|
||||
m_pTextures->removeObjectForKey(pKey->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,13 +568,12 @@ void CCTextureCache::removeTextureForKey(const char *textureKeyName)
|
|||
}
|
||||
|
||||
string fullPath = CCFileUtils::fullPathFromRelativePath(textureKeyName);
|
||||
m_pTextures->removeObjectForKey(fullPath);
|
||||
m_pTextures->removeObjectForKey(fullPath.c_str());
|
||||
}
|
||||
|
||||
CCTexture2D* CCTextureCache::textureForKey(const char* key)
|
||||
{
|
||||
std::string strKey = CCFileUtils::fullPathFromRelativePath(key);
|
||||
return m_pTextures->objectForKey(strKey);
|
||||
return (CCTexture2D*)m_pTextures->objectForKey(CCFileUtils::fullPathFromRelativePath(key));
|
||||
}
|
||||
|
||||
void CCTextureCache::reloadAllTextures()
|
||||
|
@ -585,18 +588,17 @@ void CCTextureCache::dumpCachedTextureInfo()
|
|||
unsigned int count = 0;
|
||||
unsigned int totalBytes = 0;
|
||||
|
||||
vector<string> keys = m_pTextures->allKeys();
|
||||
vector<string>::iterator iter;
|
||||
for (iter = keys.begin(); iter != keys.end(); iter++)
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pTextures, pElement)
|
||||
{
|
||||
CCTexture2D *tex = m_pTextures->objectForKey(*iter);
|
||||
CCTexture2D* tex = (CCTexture2D*)pElement->getObject();
|
||||
unsigned int bpp = tex->bitsPerPixelForFormat();
|
||||
// Each texture takes up width * height * bytesPerPixel bytes.
|
||||
unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
||||
totalBytes += bytes;
|
||||
count++;
|
||||
CCLOG("cocos2d: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB",
|
||||
(*iter).c_str(),
|
||||
pElement->getStrKey(),
|
||||
(long)tex->retainCount(),
|
||||
(long)tex->getName(),
|
||||
(long)tex->getPixelsWide(),
|
||||
|
@ -797,5 +799,5 @@ void VolatileTexture::reloadAllTextures()
|
|||
|
||||
#endif // CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
|
||||
}//namespace cocos2d
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace cocos2d {
|
|||
CCPointObject *point = (CCPointObject*)m_pParallaxArray->arr[i];
|
||||
if( point->getChild()->isEqual(child))
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(m_pParallaxArray, i);
|
||||
ccArrayRemoveObjectAtIndex(m_pParallaxArray, i, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn
|
|||
m_uMinGID = layerInfo->m_uMinGID;
|
||||
m_uMaxGID = layerInfo->m_uMaxGID;
|
||||
m_cOpacity = layerInfo->m_cOpacity;
|
||||
m_pProperties = CCStringToStringDictionary::dictionaryWithDictionary(layerInfo->getProperties());
|
||||
setProperties(CCDictionary::dictionaryWithDictionary(layerInfo->getProperties()));
|
||||
m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor();
|
||||
|
||||
// tilesetInfo
|
||||
|
@ -194,10 +194,11 @@ void CCTMXLayer::setupTiles()
|
|||
}
|
||||
|
||||
// CCTMXLayer - Properties
|
||||
CCString *CCTMXLayer::propertyNamed(const char *propertyName)
|
||||
CCString* CCTMXLayer::propertyNamed(const char *propertyName)
|
||||
{
|
||||
return m_pProperties->objectForKey(std::string(propertyName));
|
||||
return (CCString*)m_pProperties->objectForKey(propertyName);
|
||||
}
|
||||
|
||||
void CCTMXLayer::parseInternalProperties()
|
||||
{
|
||||
// if cc_vertex=automatic, then tiles will be rendered using vertexz
|
||||
|
@ -674,11 +675,11 @@ int CCTMXLayer::vertexZForPos(const CCPoint& pos)
|
|||
return ret;
|
||||
}
|
||||
|
||||
CCStringToStringDictionary * CCTMXLayer::getProperties()
|
||||
CCDictionary * CCTMXLayer::getProperties()
|
||||
{
|
||||
return m_pProperties;
|
||||
}
|
||||
void CCTMXLayer::setProperties(CCStringToStringDictionary* var)
|
||||
void CCTMXLayer::setProperties(CCDictionary* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
|
|
|
@ -26,64 +26,67 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "CCTMXObjectGroup.h"
|
||||
#include "ccMacros.h"
|
||||
namespace cocos2d {
|
||||
|
||||
//implementation CCTMXObjectGroup
|
||||
NS_CC_BEGIN
|
||||
|
||||
//implementation CCTMXObjectGroup
|
||||
|
||||
CCTMXObjectGroup::CCTMXObjectGroup()
|
||||
:m_tPositionOffset(CCPointZero)
|
||||
,m_sGroupName("")
|
||||
{
|
||||
m_pObjects = new CCMutableArray<CCStringToStringDictionary*>();
|
||||
m_pProperties = new CCStringToStringDictionary();
|
||||
}
|
||||
CCTMXObjectGroup::~CCTMXObjectGroup()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing.");
|
||||
CC_SAFE_RELEASE(m_pObjects);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
}
|
||||
CCStringToStringDictionary * CCTMXObjectGroup::objectNamed(const char *objectName)
|
||||
{
|
||||
if (m_pObjects && m_pObjects->count() > 0)
|
||||
CCTMXObjectGroup::CCTMXObjectGroup()
|
||||
:m_tPositionOffset(CCPointZero)
|
||||
,m_sGroupName("")
|
||||
{
|
||||
m_pObjects = CCArray::array();
|
||||
m_pObjects->retain();
|
||||
m_pProperties = new CCDictionary();
|
||||
}
|
||||
CCTMXObjectGroup::~CCTMXObjectGroup()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing.");
|
||||
CC_SAFE_RELEASE(m_pObjects);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
}
|
||||
CCDictionary* CCTMXObjectGroup::objectNamed(const char *objectName)
|
||||
{
|
||||
if (m_pObjects && m_pObjects->count() > 0)
|
||||
{
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pObjects, pObj)
|
||||
{
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
||||
for (it = m_pObjects->begin(); it != m_pObjects->end(); ++it)
|
||||
CCDictionary* pDict = (CCDictionary*)pObj;
|
||||
CCString *name = (CCString*)pDict->objectForKey("name");
|
||||
if (name && name->m_sString == objectName)
|
||||
{
|
||||
CCString *name = (*it)->objectForKey(std::string("name"));
|
||||
if (name && name->m_sString == objectName)
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
return pDict;
|
||||
}
|
||||
}
|
||||
// object not found
|
||||
return NULL;
|
||||
}
|
||||
CCString *CCTMXObjectGroup::propertyNamed(const char* propertyName)
|
||||
{
|
||||
return m_pProperties->objectForKey(std::string(propertyName));
|
||||
}
|
||||
// object not found
|
||||
return NULL;
|
||||
}
|
||||
CCString* CCTMXObjectGroup::propertyNamed(const char* propertyName)
|
||||
{
|
||||
return (CCString*)m_pProperties->objectForKey(propertyName);
|
||||
}
|
||||
|
||||
CCStringToStringDictionary * CCTMXObjectGroup::getProperties()
|
||||
{
|
||||
return m_pProperties;
|
||||
}
|
||||
void CCTMXObjectGroup::setProperties(CCStringToStringDictionary * properties)
|
||||
{
|
||||
CC_SAFE_RETAIN(properties);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
m_pProperties = properties;
|
||||
}
|
||||
CCMutableArray<CCStringToStringDictionary*> *CCTMXObjectGroup::getObjects()
|
||||
{
|
||||
return m_pObjects;
|
||||
}
|
||||
void CCTMXObjectGroup::setObjects(CCMutableArray<CCStringToStringDictionary*> * objects)
|
||||
{
|
||||
CC_SAFE_RETAIN(objects);
|
||||
CC_SAFE_RELEASE(m_pObjects);
|
||||
m_pObjects = objects;
|
||||
}
|
||||
CCDictionary* CCTMXObjectGroup::getProperties()
|
||||
{
|
||||
return m_pProperties;
|
||||
}
|
||||
void CCTMXObjectGroup::setProperties(CCDictionary * properties)
|
||||
{
|
||||
CC_SAFE_RETAIN(properties);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
m_pProperties = properties;
|
||||
}
|
||||
CCArray* CCTMXObjectGroup::getObjects()
|
||||
{
|
||||
return m_pObjects;
|
||||
}
|
||||
void CCTMXObjectGroup::setObjects(CCArray* objects)
|
||||
{
|
||||
CC_SAFE_RETAIN(objects);
|
||||
CC_SAFE_RELEASE(m_pObjects);
|
||||
m_pObjects = objects;
|
||||
}
|
||||
|
||||
}// namespace cocos2d
|
||||
NS_CC_END
|
||||
|
|
|
@ -101,24 +101,24 @@ CCTMXTiledMap::~CCTMXTiledMap()
|
|||
CC_SAFE_RELEASE(m_pTileProperties);
|
||||
}
|
||||
|
||||
CCMutableArray<CCTMXObjectGroup*> * CCTMXTiledMap::getObjectGroups()
|
||||
CCArray* CCTMXTiledMap::getObjectGroups()
|
||||
{
|
||||
return m_pObjectGroups;
|
||||
}
|
||||
|
||||
void CCTMXTiledMap::setObjectGroups(CCMutableArray<CCTMXObjectGroup*>* var)
|
||||
void CCTMXTiledMap::setObjectGroups(CCArray* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pObjectGroups);
|
||||
m_pObjectGroups = var;
|
||||
}
|
||||
|
||||
CCStringToStringDictionary * CCTMXTiledMap::getProperties()
|
||||
CCDictionary * CCTMXTiledMap::getProperties()
|
||||
{
|
||||
return m_pProperties;
|
||||
}
|
||||
|
||||
void CCTMXTiledMap::setProperties(CCStringToStringDictionary* var)
|
||||
void CCTMXTiledMap::setProperties(CCDictionary* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
|
@ -141,14 +141,14 @@ CCTMXLayer * CCTMXTiledMap::parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *
|
|||
CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo)
|
||||
{
|
||||
CCSize size = layerInfo->m_tLayerSize;
|
||||
CCMutableArray<CCTMXTilesetInfo*>* tilesets = mapInfo->getTilesets();
|
||||
CCArray* tilesets = mapInfo->getTilesets();
|
||||
if (tilesets && tilesets->count()>0)
|
||||
{
|
||||
CCTMXTilesetInfo *tileset = NULL;
|
||||
CCMutableArray<CCTMXTilesetInfo*>::CCMutableArrayRevIterator rit;
|
||||
for (rit = tilesets->rbegin(); rit != tilesets->rend(); ++rit)
|
||||
CCTMXTilesetInfo* tileset = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH_REVERSE(tilesets, pObj);
|
||||
{
|
||||
tileset = *rit;
|
||||
tileset = (CCTMXTilesetInfo*)pObj;
|
||||
if (tileset)
|
||||
{
|
||||
for( unsigned int y=0; y < size.height; y++ )
|
||||
|
@ -179,7 +179,7 @@ CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCT
|
|||
}
|
||||
|
||||
// If all the tiles are 0, return empty tileset
|
||||
CCLOG("cocos2d: Warning: TMX Layer '%@' has no tiles", layerInfo->m_sName.c_str());
|
||||
CCLOG("cocos2d: Warning: TMX Layer '%s' has no tiles", layerInfo->m_sName.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -203,14 +203,14 @@ void CCTMXTiledMap::buildWithMapInfo(CCTMXMapInfo* mapInfo)
|
|||
|
||||
int idx=0;
|
||||
|
||||
CCMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
|
||||
CCArray* layers = mapInfo->getLayers();
|
||||
if (layers && layers->count()>0)
|
||||
{
|
||||
CCTMXLayerInfo *layerInfo = NULL;
|
||||
CCMutableArray<CCTMXLayerInfo*>::CCMutableArrayIterator it;
|
||||
for (it = layers->begin(); it != layers->end(); ++it)
|
||||
CCTMXLayerInfo* layerInfo = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(layers, pObj)
|
||||
{
|
||||
layerInfo = *it;
|
||||
layerInfo = (CCTMXLayerInfo*)pObj;
|
||||
if (layerInfo && layerInfo->m_bVisible)
|
||||
{
|
||||
CCTMXLayer *child = parseLayer(layerInfo, mapInfo);
|
||||
|
@ -257,11 +257,11 @@ CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName)
|
|||
std::string sGroupName = groupName;
|
||||
if (m_pObjectGroups && m_pObjectGroups->count()>0)
|
||||
{
|
||||
CCTMXObjectGroup *objectGroup;
|
||||
CCMutableArray<CCTMXObjectGroup*>::CCMutableArrayIterator it;
|
||||
for (it = m_pObjectGroups->begin(); it != m_pObjectGroups->end(); ++it)
|
||||
CCTMXObjectGroup* objectGroup = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pObjectGroups, pObj)
|
||||
{
|
||||
objectGroup = (CCTMXObjectGroup*)(*it);
|
||||
objectGroup = (CCTMXObjectGroup*)(pObj);
|
||||
if (objectGroup && objectGroup->getGroupName() == sGroupName)
|
||||
{
|
||||
return objectGroup;
|
||||
|
@ -273,13 +273,14 @@ CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCString * CCTMXTiledMap::propertyNamed(const char *propertyName)
|
||||
CCString* CCTMXTiledMap::propertyNamed(const char *propertyName)
|
||||
{
|
||||
return m_pProperties->objectForKey(std::string(propertyName));
|
||||
return (CCString*)m_pProperties->objectForKey(propertyName);
|
||||
}
|
||||
CCDictionary<std::string, CCString*> * CCTMXTiledMap::propertiesForGID(int GID)
|
||||
|
||||
CCDictionary* CCTMXTiledMap::propertiesForGID(int GID)
|
||||
{
|
||||
return m_pTileProperties->objectForKey(GID);
|
||||
return (CCDictionary*)m_pTileProperties->objectForKey(GID);
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "CCTouchHandler.h"
|
||||
#include "CCMutableArray.h"
|
||||
#include "CCArray.h"
|
||||
#include "CCSet.h"
|
||||
#include "CCTouch.h"
|
||||
#include "CCTexture2D.h"
|
||||
|
@ -36,9 +36,9 @@ THE SOFTWARE.
|
|||
/**
|
||||
* Used for sort
|
||||
*/
|
||||
static bool less(const cocos2d::CCTouchHandler *p1, const cocos2d::CCTouchHandler *p2)
|
||||
static int less(const void* p1, const void* p2)
|
||||
{
|
||||
return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority();
|
||||
return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority() ? 1 : -1;
|
||||
}
|
||||
|
||||
namespace cocos2d {
|
||||
|
@ -81,10 +81,12 @@ CCTouchDispatcher* CCTouchDispatcher::sharedDispatcher(void)
|
|||
bool CCTouchDispatcher::init(void)
|
||||
{
|
||||
m_bDispatchEvents = true;
|
||||
m_pTargetedHandlers = new CCMutableArray<CCTouchHandler*>(8);
|
||||
m_pStandardHandlers = new CCMutableArray<CCTouchHandler*>(4);
|
||||
m_pTargetedHandlers = CCArray::arrayWithCapacity(8);
|
||||
m_pTargetedHandlers->retain();
|
||||
m_pStandardHandlers = CCArray::arrayWithCapacity(4);
|
||||
m_pStandardHandlers->retain();
|
||||
|
||||
m_pHandlersToAdd = new CCMutableArray<CCTouchHandler*>(8);
|
||||
m_pHandlersToAdd = CCArray::arrayWithCapacity(8);
|
||||
m_pHandlersToRemove = ccCArrayNew(8);
|
||||
|
||||
m_bToRemove = false;
|
||||
|
@ -113,14 +115,14 @@ CCTouchDispatcher::~CCTouchDispatcher(void)
|
|||
//
|
||||
// handlers management
|
||||
//
|
||||
void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, CCMutableArray<CCTouchHandler*> *pArray)
|
||||
void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, CCArray *pArray)
|
||||
{
|
||||
unsigned int u = 0;
|
||||
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
for (iter = pArray->begin(); iter != pArray->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(pArray, pObj)
|
||||
{
|
||||
CCTouchHandler *h = *iter;
|
||||
CCTouchHandler *h = (CCTouchHandler *)pObj;
|
||||
if (h)
|
||||
{
|
||||
if (h->getPriority() < pHandler->getPriority())
|
||||
|
@ -136,7 +138,7 @@ void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, CCMutableArray
|
|||
}
|
||||
}
|
||||
|
||||
pArray->insertObjectAtIndex(pHandler, u);
|
||||
pArray->insertObject(pHandler, u);
|
||||
}
|
||||
|
||||
void CCTouchDispatcher::addStandardDelegate(CCTouchDelegate *pDelegate, int nPriority)
|
||||
|
@ -188,14 +190,14 @@ void CCTouchDispatcher::addTargetedDelegate(CCTouchDelegate *pDelegate, int nPri
|
|||
void CCTouchDispatcher::forceRemoveDelegate(CCTouchDelegate *pDelegate)
|
||||
{
|
||||
CCTouchHandler *pHandler;
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
|
||||
// XXX: remove it from both handlers ???
|
||||
|
||||
// remove handler from m_pStandardHandlers
|
||||
for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pStandardHandlers, pObj)
|
||||
{
|
||||
pHandler = *iter;
|
||||
pHandler = (CCTouchHandler*)pObj;
|
||||
if (pHandler && pHandler->getDelegate() == pDelegate)
|
||||
{
|
||||
m_pStandardHandlers->removeObject(pHandler);
|
||||
|
@ -204,9 +206,9 @@ void CCTouchDispatcher::forceRemoveDelegate(CCTouchDelegate *pDelegate)
|
|||
}
|
||||
|
||||
// remove handler from m_pTargetedHandlers
|
||||
for (iter = m_pTargetedHandlers->begin(); iter != m_pTargetedHandlers->end(); ++iter)
|
||||
CCARRAY_FOREACH(m_pTargetedHandlers, pObj)
|
||||
{
|
||||
pHandler = *iter;
|
||||
pHandler = (CCTouchHandler*)pObj;
|
||||
if (pHandler && pHandler->getDelegate() == pDelegate)
|
||||
{
|
||||
m_pTargetedHandlers->removeObject(pHandler);
|
||||
|
@ -263,47 +265,49 @@ void CCTouchDispatcher::removeAllDelegates(void)
|
|||
|
||||
CCTouchHandler* CCTouchDispatcher::findHandler(CCTouchDelegate *pDelegate)
|
||||
{
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
|
||||
for (iter = m_pTargetedHandlers->begin(); iter != m_pTargetedHandlers->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pTargetedHandlers, pObj)
|
||||
{
|
||||
if ((*iter)->getDelegate() == pDelegate)
|
||||
CCTouchHandler* pHandler = (CCTouchHandler*)pObj;
|
||||
if (pHandler->getDelegate() == pDelegate)
|
||||
{
|
||||
return *iter;
|
||||
return pHandler;
|
||||
}
|
||||
}
|
||||
|
||||
for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter)
|
||||
CCARRAY_FOREACH(m_pStandardHandlers, pObj)
|
||||
{
|
||||
if ((*iter)->getDelegate() == pDelegate)
|
||||
CCTouchHandler* pHandler = (CCTouchHandler*)pObj;
|
||||
if (pHandler->getDelegate() == pDelegate)
|
||||
{
|
||||
return *iter;
|
||||
return pHandler;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCTouchHandler* CCTouchDispatcher::findHandler(CCMutableArray<CCTouchHandler*> *pArray, CCTouchDelegate *pDelegate)
|
||||
CCTouchHandler* CCTouchDispatcher::findHandler(CCArray* pArray, CCTouchDelegate *pDelegate)
|
||||
{
|
||||
CCAssert(pArray != NULL && pDelegate != NULL, "");
|
||||
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
|
||||
for (iter = pArray->begin(); iter != pArray->end(); ++iter)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(pArray, pObj)
|
||||
{
|
||||
if ((*iter)->getDelegate() == pDelegate)
|
||||
CCTouchHandler* pHandle = (CCTouchHandler*)pObj;
|
||||
if (pHandle->getDelegate() == pDelegate)
|
||||
{
|
||||
return *iter;
|
||||
return pHandle;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CCTouchDispatcher::rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray)
|
||||
void CCTouchDispatcher::rearrangeHandlers(CCArray *pArray)
|
||||
{
|
||||
std::sort(pArray->begin(), pArray->end(), less);
|
||||
// FIXME: qsort is not supported in bada1.0, so we must implement it ourselves.
|
||||
qsort(pArray->data->arr, pArray->data->num, sizeof(pArray->data->arr[0]), less);
|
||||
}
|
||||
|
||||
void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)
|
||||
|
@ -350,12 +354,12 @@ void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int u
|
|||
for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter)
|
||||
{
|
||||
pTouch = (CCTouch *)(*setIter);
|
||||
CCTargetedTouchHandler *pHandler;
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator arrayIter;
|
||||
for (arrayIter = m_pTargetedHandlers->begin(); arrayIter != m_pTargetedHandlers->end(); ++arrayIter)
|
||||
/*for (unsigned int i = 0; i < m_pTargetedHandlers->num; ++i)*/
|
||||
|
||||
CCTargetedTouchHandler *pHandler = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pTargetedHandlers, pObj)
|
||||
{
|
||||
pHandler = (CCTargetedTouchHandler *)(*arrayIter);
|
||||
pHandler = (CCTargetedTouchHandler *)(pObj);
|
||||
|
||||
if (! pHandler)
|
||||
{
|
||||
|
@ -411,11 +415,11 @@ void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int u
|
|||
//
|
||||
if (uStandardHandlersCount > 0 && pMutableTouches->count() > 0)
|
||||
{
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
CCStandardTouchHandler *pHandler;
|
||||
for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter)
|
||||
CCStandardTouchHandler *pHandler = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pStandardHandlers, pObj)
|
||||
{
|
||||
pHandler = (CCStandardTouchHandler*)(*iter);
|
||||
pHandler = (CCStandardTouchHandler*)(pObj);
|
||||
|
||||
if (! pHandler)
|
||||
{
|
||||
|
@ -463,11 +467,11 @@ void CCTouchDispatcher::touches(CCSet *pTouches, CCEvent *pEvent, unsigned int u
|
|||
if (m_bToAdd)
|
||||
{
|
||||
m_bToAdd = false;
|
||||
CCMutableArray<CCTouchHandler*>::CCMutableArrayIterator iter;
|
||||
CCTouchHandler *pHandler;
|
||||
for (iter = m_pHandlersToAdd->begin(); iter != m_pHandlersToAdd->end(); ++iter)
|
||||
CCTouchHandler* pHandler = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_pHandlersToAdd, pObj)
|
||||
{
|
||||
pHandler = *iter;
|
||||
pHandler = (CCTouchHandler*)pObj;
|
||||
if (! pHandler)
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ACTION_MANUAL_LAYER = 0,
|
||||
|
|
|
@ -1 +1 @@
|
|||
7593bccdf37e94e6af9b7bfec82d6931c746f428
|
||||
6b30e04685cc62b5daa0628f9bb038bc42bae923
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include <string>
|
||||
|
||||
class SpriteTestDemo : public CCLayer
|
||||
{
|
||||
|
|
|
@ -615,13 +615,13 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
|
||||
////----UXLOG("----> Iterating over all the group objets");
|
||||
CCTMXObjectGroup* group = map->objectGroupNamed("Object Group 1");
|
||||
CCMutableArray<CCStringToStringDictionary*> * objects = group->getObjects();
|
||||
CCArray* objects = group->getObjects();
|
||||
|
||||
CCStringToStringDictionary* dict;
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
||||
for( it = objects->begin(); it != objects->end(); it++)
|
||||
CCDictionary* dict = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(objects, pObj)
|
||||
{
|
||||
dict = (*it);//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
dict = (CCDictionary*)pObj;//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
|
||||
if(!dict)
|
||||
break;
|
||||
|
@ -639,24 +639,23 @@ void TMXOrthoObjectsTest::draw()
|
|||
CCTMXTiledMap* map = (CCTMXTiledMap*) getChildByTag(kTagTileMap);
|
||||
CCTMXObjectGroup* group = map->objectGroupNamed("Object Group 1");
|
||||
|
||||
CCMutableArray<CCStringToStringDictionary*> * objects = group->getObjects();
|
||||
CCStringToStringDictionary* dict;
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
||||
|
||||
for( it = objects->begin(); it != objects->end(); it++)
|
||||
CCArray* objects = group->getObjects();
|
||||
CCDictionary* dict = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(objects, pObj)
|
||||
{
|
||||
dict = (*it);//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
dict = (CCDictionary*)pObj;//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
|
||||
if(!dict)
|
||||
break;
|
||||
std::string key = "x";
|
||||
int x = dict->objectForKey(key)->toInt();
|
||||
const char* key = "x";
|
||||
int x = ((CCString*)dict->objectForKey(key))->toInt();
|
||||
key = "y";
|
||||
int y = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("y"))->getNumber();
|
||||
int y = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("y"))->getNumber();
|
||||
key = "width";
|
||||
int width = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("width"))->getNumber();
|
||||
int width = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("width"))->getNumber();
|
||||
key = "height";
|
||||
int height = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("height"))->getNumber();
|
||||
int height = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("height"))->getNumber();
|
||||
|
||||
glLineWidth(3);
|
||||
|
||||
|
@ -697,15 +696,13 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
CCTMXObjectGroup* group = map->objectGroupNamed("Object Group 1");
|
||||
|
||||
//UxMutableArray* objects = group->objects();
|
||||
CCMutableArray<CCStringToStringDictionary*> * objects = group->getObjects();
|
||||
CCArray* objects = group->getObjects();
|
||||
//UxMutableDictionary<std::string>* dict;
|
||||
CCStringToStringDictionary* dict;
|
||||
//CCMutableArray<CCObject*>::CCMutableArrayIterator it;
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
||||
|
||||
for( it = objects->begin(); it != objects->end(); it++)
|
||||
CCDictionary* dict;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(objects, pObj)
|
||||
{
|
||||
dict = (*it);
|
||||
dict = (CCDictionary*)pObj;
|
||||
|
||||
if(!dict)
|
||||
break;
|
||||
|
@ -719,24 +716,23 @@ void TMXIsoObjectsTest::draw()
|
|||
CCTMXTiledMap *map = (CCTMXTiledMap*) getChildByTag(kTagTileMap);
|
||||
CCTMXObjectGroup *group = map->objectGroupNamed("Object Group 1");
|
||||
|
||||
CCMutableArray<CCStringToStringDictionary*> * objects = group->getObjects();
|
||||
CCStringToStringDictionary* dict;
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
||||
|
||||
for( it = objects->begin(); it != objects->end(); it++)
|
||||
CCArray* objects = group->getObjects();
|
||||
CCDictionary* dict;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(objects, pObj)
|
||||
{
|
||||
dict = (*it);//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
dict = (CCDictionary*)pObj;//dynamic_cast<CCStringToStringDictionary*>(*it);
|
||||
|
||||
if(!dict)
|
||||
break;
|
||||
std::string key = "x";
|
||||
int x = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("x"))->getNumber();
|
||||
const char* key = "x";
|
||||
int x = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("x"))->getNumber();
|
||||
key = "y";
|
||||
int y = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("y"))->getNumber();
|
||||
int y = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("y"))->getNumber();
|
||||
key = "width";
|
||||
int width = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("width"))->getNumber();
|
||||
int width = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("width"))->getNumber();
|
||||
key = "height";
|
||||
int height = dict->objectForKey(key)->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("height"))->getNumber();
|
||||
int height = ((CCString*)dict->objectForKey(key))->toInt();//dynamic_cast<NSNumber*>(dict->objectForKey("height"))->getNumber();
|
||||
|
||||
glLineWidth(3);
|
||||
|
||||
|
@ -1412,26 +1408,25 @@ void TMXGIDObjectsTest::draw()
|
|||
CCTMXTiledMap *map = (CCTMXTiledMap*)getChildByTag(kTagTileMap);
|
||||
CCTMXObjectGroup *group = map->objectGroupNamed("Object Layer 1");
|
||||
|
||||
CCMutableArray<CCStringToStringDictionary*> *array = group->getObjects();
|
||||
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator iter;
|
||||
CCStringToStringDictionary *dict;
|
||||
|
||||
for (iter = array->begin(); iter != array->end(); ++iter)
|
||||
CCArray *array = group->getObjects();
|
||||
CCDictionary* dict;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(array, pObj)
|
||||
{
|
||||
dict = *iter;
|
||||
dict = (CCDictionary*)pObj;
|
||||
if(!dict)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::string key = "x";
|
||||
int x = dict->objectForKey(key)->toInt();
|
||||
const char* key = "x";
|
||||
int x = ((CCString*)dict->objectForKey(key))->toInt();
|
||||
key = "y";
|
||||
int y = dict->objectForKey(key)->toInt();
|
||||
int y = ((CCString*)dict->objectForKey(key))->toInt();
|
||||
key = "width";
|
||||
int width = dict->objectForKey(key)->toInt();
|
||||
int width = ((CCString*)dict->objectForKey(key))->toInt();
|
||||
key = "height";
|
||||
int height = dict->objectForKey(key)->toInt();
|
||||
int height = ((CCString*)dict->objectForKey(key))->toInt();
|
||||
|
||||
glLineWidth(3);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ PongLayer::PongLayer()
|
|||
|
||||
CCTexture2D* paddleTexture = CCTextureCache::sharedTextureCache()->addImage(s_Paddle);
|
||||
|
||||
CCMutableArray<CCObject *> *paddlesM = new CCMutableArray<CCObject *>(4);
|
||||
CCArray *paddlesM = CCArray::arrayWithCapacity(4);
|
||||
|
||||
Paddle* paddle = Paddle::paddleWithTexture(paddleTexture);
|
||||
paddle->setPosition( CCPointMake(160, 15) );
|
||||
|
@ -72,12 +72,12 @@ PongLayer::PongLayer()
|
|||
paddle->setPosition( CCPointMake(160, 480 - kStatusBarHeight - 100) );
|
||||
paddlesM->addObject( paddle );
|
||||
|
||||
m_paddles = paddlesM->copy();
|
||||
m_paddles = (CCArray*)paddlesM->copy();
|
||||
|
||||
CCMutableArray<CCObject *>::CCMutableArrayIterator it;
|
||||
for(it = m_paddles->begin(); it != m_paddles->end(); it++)
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_paddles, pObj)
|
||||
{
|
||||
paddle = (Paddle*)(*it);
|
||||
paddle = (Paddle*)(pObj);
|
||||
|
||||
if(!paddle)
|
||||
break;
|
||||
|
@ -85,8 +85,6 @@ PongLayer::PongLayer()
|
|||
addChild(paddle);
|
||||
}
|
||||
|
||||
paddlesM->release();
|
||||
|
||||
schedule( schedule_selector(PongLayer::doStep) );
|
||||
}
|
||||
|
||||
|
@ -109,11 +107,11 @@ void PongLayer::doStep(ccTime delta)
|
|||
{
|
||||
m_ball->move(delta);
|
||||
|
||||
Paddle* paddle;
|
||||
CCMutableArray<CCObject *>::CCMutableArrayIterator it;
|
||||
for(it = m_paddles->begin(); it != m_paddles->end(); it++)
|
||||
Paddle* paddle = NULL;
|
||||
CCObject* pObj = NULL;
|
||||
CCARRAY_FOREACH(m_paddles, pObj)
|
||||
{
|
||||
paddle = (Paddle*)(*it);
|
||||
paddle = (Paddle*)(pObj);
|
||||
|
||||
if(!paddle)
|
||||
break;
|
||||
|
|
|
@ -20,7 +20,7 @@ class Ball;
|
|||
class PongLayer : public CCLayer
|
||||
{
|
||||
Ball* m_ball;
|
||||
CCMutableArray<CCObject *> *m_paddles;
|
||||
CCArray* m_paddles;
|
||||
CCPoint m_ballStartingVelocity;
|
||||
public:
|
||||
PongLayer();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "cocos2d.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace std;
|
||||
|
||||
class TestScene : public CCScene
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue