diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4de921cdd8..1c9f312302 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -622,7 +622,7 @@ void Director::popScene(void) else { _sendCleanupToScene = true; - _nextScene = (Scene*)_scenesStack->objectAtIndex(c - 1); + _nextScene = (Scene*)_scenesStack->getObjectAtIndex(c - 1); } } @@ -650,7 +650,7 @@ void Director::popToSceneStackLevel(int level) // pop stack until reaching desired level while (c > level) { - Scene *current = (Scene*)_scenesStack->lastObject(); + Scene *current = (Scene*)_scenesStack->getLastObject(); if (current->isRunning()) { @@ -663,7 +663,7 @@ void Director::popToSceneStackLevel(int level) --c; } - _nextScene = (Scene*)_scenesStack->lastObject(); + _nextScene = (Scene*)_scenesStack->getLastObject(); _sendCleanupToScene = false; } diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index fbfcc3b529..5b8956ba8d 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -687,7 +687,7 @@ void Scheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID) { for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--) { - SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->objectAtIndex(i)); + SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); if (pEntry->getEntryId() == (int)uScheduleScriptEntryID) { pEntry->markedForDeletion(); @@ -909,7 +909,7 @@ void Scheduler::update(float dt) { for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--) { - SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->objectAtIndex(i)); + SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); if (pEntry->isMarkedForDeletion()) { _scriptHandlerEntries->removeObjectAtIndex(i); diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index f9c384e1f3..7f64a56214 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -206,13 +206,13 @@ Sequence* Sequence::create(Array* arrayOfActions) unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); + FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); if (count > 1) { for (unsigned int i = 1; i < count; ++i) { - prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); + prev = createWithTwoActions(prev, static_cast(arrayOfActions->getObjectAtIndex(i))); } } else @@ -578,12 +578,12 @@ Spawn* Spawn::create(Array *arrayOfActions) { unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); + FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); if (count > 1) { for (unsigned int i = 1; i < arrayOfActions->count(); ++i) { - prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); + prev = createWithTwoActions(prev, static_cast(arrayOfActions->getObjectAtIndex(i))); } } else @@ -2107,7 +2107,7 @@ void Animate::update(float t) float splitTime = _splitTimes->at(i); if( splitTime <= t ) { - AnimationFrame* frame = static_cast(frames->objectAtIndex(i)); + AnimationFrame* frame = static_cast(frames->getObjectAtIndex(i)); frameToDisplay = frame->getSpriteFrame(); static_cast(_target)->setDisplayFrame(frameToDisplay); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 114fc1b7ec..2220319f0a 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -90,7 +90,7 @@ Array* Array::create(Object* object, ...) { array->addObject(object); Object *i = va_arg(args, Object*); - while(i) + while (i) { array->addObject(i); i = va_arg(args, Object*); @@ -129,12 +129,12 @@ Array* Array::createWithCapacity(unsigned int capacity) Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); - if (pRet != NULL) + Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); + if (ret != nullptr) { pRet->autorelease(); } - return pRet; + return ret; } Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) @@ -163,7 +163,7 @@ bool Array::initWithObjects(Object* object, ...) bool ret = false; do { - CC_BREAK_IF(object == NULL); + CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); @@ -172,7 +172,7 @@ bool Array::initWithObjects(Object* object, ...) { this->addObject(object); Object* i = va_arg(args, Object*); - while(i) + while (i) { this->addObject(i); i = va_arg(args, Object*); @@ -200,10 +200,6 @@ bool Array::initWithArray(Array* otherArray) int Array::getIndexOfObject(Object* object) const { -// auto it = std::find(data.begin(), data.end(), object ); -// if( it == data.end() ) -// return -1; -// return it - std::begin(data); auto it = data.begin(); for (int i = 0; it != data.end(); ++it, ++i) @@ -239,7 +235,7 @@ Object* Array::getRandomObject() bool Array::containsObject(Object* object) const { int i = this->getIndexOfObject(object); - return (i >=0 ); + return (i >=0); } bool Array::isEqualToArray(Array* otherArray) @@ -282,14 +278,6 @@ void Array::removeLastObject(bool releaseObj) void Array::removeObject(Object* object, bool releaseObj /* ignored */) { -// auto begin = data.begin(); -// auto end = data.end(); -// -// auto it = std::find( begin, end, object); -// if( it != end ) { -// data.erase(it); -// } - auto it = data.begin(); for (; it != data.end(); ++it) { @@ -344,7 +332,6 @@ void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject /* ignored */) { -// auto obj = data[index]; data[index] = object; } @@ -368,9 +355,9 @@ Array* Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); - Object* obj = NULL; - Object* tmpObj = NULL; - Clonable* clonable = NULL; + Object* obj = nullptr; + Object* tmpObj = nullptr; + Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); @@ -402,13 +389,13 @@ void Array::acceptVisitor(DataVisitor &visitor) #else Array::Array() -: data(NULL) +: data(nullptr) { // init(); } Array::Array(unsigned int capacity) -: data(NULL) +: data(nullptr) { initWithCapacity(capacity); } @@ -455,7 +442,7 @@ Array* Array::create(Object* object, ...) { array->addObject(object); Object *i = va_arg(args, Object*); - while(i) + while (i) { array->addObject(i); i = va_arg(args, Object*); @@ -494,12 +481,12 @@ Array* Array::createWithCapacity(unsigned int capacity) Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); - if (pRet != NULL) + Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); + if (ret != nullptr) { - pRet->autorelease(); + ret->autorelease(); } - return pRet; + return ret; } Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) @@ -534,7 +521,7 @@ bool Array::initWithObjects(Object* object, ...) bool ret = false; do { - CC_BREAK_IF(object == NULL); + CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); @@ -543,7 +530,7 @@ bool Array::initWithObjects(Object* object, ...) { this->addObject(object); Object* i = va_arg(args, Object*); - while(i) + while (i) { this->addObject(i); i = va_arg(args, Object*); @@ -588,9 +575,9 @@ int Array::getIndexOfObject(Object* object) const Object* Array::getRandomObject() { - if (data->num==0) + if (data->num == 0) { - return NULL; + return nullptr; } float r = CCRANDOM_0_1(); @@ -639,7 +626,8 @@ void Array::setObject(Object* object, int index) { CCASSERT(index>=0 && index < count(), "Invalid index"); - if( object != data->arr[index] ) { + if (object != data->arr[index]) + { data->arr[index]->release(); data->arr[index] = object; object->retain(); @@ -685,13 +673,13 @@ void Array::fastRemoveObject(Object* object) void Array::exchangeObject(Object* object1, Object* object2) { unsigned int index1 = ccArrayGetIndexOfObject(data, object1); - if(index1 == UINT_MAX) + if (index1 == UINT_MAX) { return; } unsigned int index2 = ccArrayGetIndexOfObject(data, object2); - if(index2 == UINT_MAX) + if (index2 == UINT_MAX) { return; } @@ -721,7 +709,7 @@ void Array::reverseObjects() for (int i = 0; i < count ; i++) { ccArraySwapObjectsAtIndexes(data, i, maxIndex); - maxIndex--; + --maxIndex; } } } @@ -742,9 +730,9 @@ Array* Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); - Object* obj = NULL; - Object* tmpObj = NULL; - Clonable* clonable = NULL; + Object* obj = nullptr; + Object* tmpObj = nullptr; + Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index aba86abb54..1ca34a46a5 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -50,10 +50,10 @@ class RCPtr public: //Construct using a C pointer //e.g. RCPtr< T > x = new T(); - RCPtr(T* ptr = NULL) + RCPtr(T* ptr = nullptr) : _ptr(ptr) { - if(ptr != NULL) {ptr->retain();} + if(ptr != nullptr) {ptr->retain();} } //Copy constructor @@ -69,13 +69,13 @@ public: : _ptr(ptr._ptr) { // printf("Array: Move Constructor: %p\n", this); - ptr._ptr = NULL; + ptr._ptr = nullptr; } ~RCPtr() { // printf("Array: Destructor: %p\n", this); - if(_ptr != NULL) {_ptr->release();} + if(_ptr != nullptr) {_ptr->release();} } //Assign a pointer @@ -87,8 +87,8 @@ public: //The following grab and release operations have to be performed //in that order to handle the case where ptr == _ptr //(See comment below by David Garlisch) - if(ptr != NULL) {ptr->retain();} - if(_ptr != NULL) {_ptr->release();} + if(ptr != nullptr) {ptr->retain();} + if(_ptr != nullptr) {_ptr->release();} _ptr = ptr; return (*this); } @@ -113,7 +113,7 @@ public: T* operator->() const {return _ptr;} //x->member T &operator*() const {return *_ptr;} //*x, (*x).member explicit operator T*() const {return _ptr;} //T* y = x; - explicit operator bool() const {return _ptr != NULL;} //if(x) {/*x is not NULL*/} + explicit operator bool() const {return _ptr != nullptr;} //if(x) {/*x is not NULL*/} bool operator==(const RCPtr &ptr) {return _ptr == ptr._ptr;} bool operator==(const T *ptr) {return _ptr == ptr;} @@ -273,7 +273,8 @@ public: // Querying an Array /** Returns element count of the array */ - unsigned int count() const { + unsigned int count() const + { #if CC_USE_ARRAY_VECTOR return data.size(); #else @@ -281,7 +282,8 @@ public: #endif } /** Returns capacity of the array */ - unsigned int capacity() const { + unsigned int capacity() const + { #if CC_USE_ARRAY_VECTOR return data.capacity(); #else @@ -293,8 +295,9 @@ public: CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); } /** Returns an element with a certain index */ - Object* getObjectAtIndex(int index) { - CCASSERT(index>=0 && index < count(), "index out of range in objectAtIndex()"); + Object* getObjectAtIndex(int index) + { + CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); #if CC_USE_ARRAY_VECTOR return data[index].get(); #else @@ -303,12 +306,14 @@ public: } CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); } /** Returns the last element of the array */ - Object* getLastObject() { + Object* getLastObject() + { #if CC_USE_ARRAY_VECTOR return data.back().get(); #else - if( data->num > 0 ) + if(data->num > 0) return data->arr[data->num-1]; + return nullptr; #endif } @@ -331,7 +336,8 @@ public: /** sets a certain object at a certain index */ void setObject(Object* object, int index); /** sets a certain object at a certain index without retaining. Use it with caution */ - void fastSetObject(Object* object, int index) { + void fastSetObject(Object* object, int index) + { #if CC_USE_ARRAY_VECTOR setObject(object, index); #else @@ -340,12 +346,13 @@ public: #endif } - void swap( int indexOne, int indexTwo ) { + void swap( int indexOne, int indexTwo ) + { CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); #if CC_USE_ARRAY_VECTOR - std::swap( data[indexOne], data[indexTwo] ); + std::swap(data[indexOne], data[indexTwo]); #else - std::swap( data->arr[indexOne], data->arr[indexTwo] ); + std::swap(data->arr[indexOne], data->arr[indexTwo]); #endif } @@ -398,7 +405,7 @@ public: const_iterator cend() { return data.cend(); } #else - class ArrayIterator : public std::iterator + class ArrayIterator : public std::iterator { public: ArrayIterator(int index, Array *array) : _index(index), _parent(array) {} @@ -412,13 +419,59 @@ public: ArrayIterator operator++(int dummy) { ArrayIterator tmp(*this); - (*this)++; + ++_index; return tmp; } + + ArrayIterator& operator--() + { + --_index; + return *this; + } + ArrayIterator operator--(int dummy) + { + ArrayIterator tmp(*this); + --_index; + return tmp; + } + + int operator-(const ArrayIterator& rhs) const + { + return _index - rhs._index; + } + ArrayIterator operator-(int d) + { + _index -= d; + return *this; + } + const ArrayIterator& operator-=(int d) + { + _index -= d; + return *this; + } + + ArrayIterator operator+(int d) + { + _index += d; + return *this; + } + + const ArrayIterator& operator+=(int d) + { + _index += d; + return *this; + } + + // add these function to make compiler happy when using std::sort(), it is meaningless + bool operator>=(const ArrayIterator& rhs) const { return false; } + bool operator<=(const ArrayIterator& rhs) const { return false; } + bool operator>(const ArrayIterator& rhs) const { return false; } + bool operator<(const ArrayIterator& rhs) const { return false; } + bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; } bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; } - Object* operator*() { return _parent->getObjectAtIndex(_index); } - Object* operator->() { return _parent->getObjectAtIndex(_index); } + reference operator*() { return _parent->data->arr[_index]; } + value_type operator->() { return _parent->data->arr[_index];; } private: int _index; diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index fba96dced5..a62b46f192 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -165,10 +165,10 @@ void PoolManager::pop() // if(nCount > 1) // { -// _curReleasePool = _releasePoolStack->objectAtIndex(nCount - 2); +// _curReleasePool = _releasePoolStack->getObjectAtIndex(nCount - 2); // return; // } - _curReleasePool = (AutoreleasePool*)_releasePoolStack->objectAtIndex(nCount - 2); + _curReleasePool = (AutoreleasePool*)_releasePoolStack->getObjectAtIndex(nCount - 2); } /*_curReleasePool = NULL;*/ diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index f7412a4fff..6a79b8f929 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -340,7 +340,7 @@ Object* Dictionary::randomObject() return NULL; } - Object* key = allKeys()->randomObject(); + Object* key = allKeys()->getRandomObject(); if (_dictType == kDictInt) { diff --git a/cocos2dx/label_nodes/CCLabel.cpp b/cocos2dx/label_nodes/CCLabel.cpp index 345c62c138..4af7aff109 100644 --- a/cocos2dx/label_nodes/CCLabel.cpp +++ b/cocos2dx/label_nodes/CCLabel.cpp @@ -444,7 +444,7 @@ Sprite * Label::getSprite() { if (_spriteArrayCache.count()) { - Sprite *retSprite = (Sprite *) _spriteArrayCache.lastObject(); + Sprite *retSprite = (Sprite *) _spriteArrayCache.getLastObject(); _spriteArrayCache.removeLastObject(); return retSprite; } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index e9f968f54a..8416ae57f1 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1088,7 +1088,7 @@ bool LayerMultiplex::initWithLayers(Layer *layer, va_list params) } _enabledLayer = 0; - this->addChild((Node*)_layers->objectAtIndex(_enabledLayer)); + this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer)); return true; } @@ -1104,7 +1104,7 @@ bool LayerMultiplex::initWithArray(Array* arrayOfLayers) _layers->retain(); _enabledLayer = 0; - this->addChild((Node*)_layers->objectAtIndex(_enabledLayer)); + this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer)); return true; } return false; @@ -1114,25 +1114,25 @@ void LayerMultiplex::switchTo(unsigned int n) { CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" ); - this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true); + this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true); _enabledLayer = n; - this->addChild((Node*)_layers->objectAtIndex(n)); + this->addChild((Node*)_layers->getObjectAtIndex(n)); } void LayerMultiplex::switchToAndReleaseMe(unsigned int n) { CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" ); - this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true); + this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true); //[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]]; _layers->replaceObjectAtIndex(_enabledLayer, NULL); _enabledLayer = n; - this->addChild((Node*)_layers->objectAtIndex(n)); + this->addChild((Node*)_layers->getObjectAtIndex(n)); } NS_CC_END diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 37747938e9..5542d58282 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -808,7 +808,7 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandle for (unsigned int z=0; z < menuItems->count(); z++) { - MenuItem* menuItem = (MenuItem*)menuItems->objectAtIndex(z); + MenuItem* menuItem = (MenuItem*)menuItems->getObjectAtIndex(z); pRet->_subItems->addObject(menuItem); } @@ -826,7 +826,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba for (unsigned int z=0; z < menuItems->count(); z++) { - MenuItem* menuItem = (MenuItem*)menuItems->objectAtIndex(z); + MenuItem* menuItem = (MenuItem*)menuItems->getObjectAtIndex(z); pRet->_subItems->addObject(menuItem); } @@ -939,7 +939,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) currentItem->removeFromParentAndCleanup(false); } - MenuItem* item = (MenuItem*)_subItems->objectAtIndex(_selectedIndex); + MenuItem* item = (MenuItem*)_subItems->getObjectAtIndex(_selectedIndex); this->addChild(item, 0, kCurrentItem); Size s = item->getContentSize(); this->setContentSize(s); @@ -950,13 +950,13 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) void MenuItemToggle::selected() { MenuItem::selected(); - static_cast(_subItems->objectAtIndex(_selectedIndex))->selected(); + static_cast(_subItems->getObjectAtIndex(_selectedIndex))->selected(); } void MenuItemToggle::unselected() { MenuItem::unselected(); - static_cast(_subItems->objectAtIndex(_selectedIndex))->unselected(); + static_cast(_subItems->getObjectAtIndex(_selectedIndex))->unselected(); } void MenuItemToggle::activate() @@ -989,7 +989,7 @@ void MenuItemToggle::setEnabled(bool enabled) MenuItem* MenuItemToggle::getSelectedItem() { - return static_cast(_subItems->objectAtIndex(_selectedIndex)); + return static_cast(_subItems->getObjectAtIndex(_selectedIndex)); } NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index deb3a8f401..88c904539f 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -186,7 +186,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) if (pos != 0) { - ParticleSystem* p = (ParticleSystem*)_children->objectAtIndex(pos-1); + ParticleSystem* p = (ParticleSystem*)_children->getObjectAtIndex(pos-1); atlasIndex = p->getAtlasIndex() + p->getTotalParticles(); } @@ -274,7 +274,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) int newAtlasIndex = 0; for( unsigned int i=0;i < _children->count();i++) { - ParticleSystem* pNode = (ParticleSystem*)_children->objectAtIndex(i); + ParticleSystem* pNode = (ParticleSystem*)_children->getObjectAtIndex(i); if( pNode == child ) { newAtlasIndex = child->getAtlasIndex(); @@ -302,7 +302,7 @@ void ParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* ne for( unsigned int i=0; i < count; i++ ) { - Node* pNode = (Node *)_children->objectAtIndex(i); + Node* pNode = (Node *)_children->getObjectAtIndex(i); // new index if( pNode->getZOrder() > z && ! foundNewIdx ) @@ -349,7 +349,7 @@ unsigned int ParticleBatchNode::searchNewPositionInChildrenForZ(int z) for( unsigned int i=0; i < count; i++ ) { - Node *child = (Node *)_children->objectAtIndex(i); + Node *child = (Node *)_children->getObjectAtIndex(i); if (child->getZOrder() > z) { return i; @@ -385,7 +385,7 @@ void ParticleBatchNode::removeChild(Node* aChild, bool cleanup) void ParticleBatchNode::removeChildAtIndex(unsigned int index, bool doCleanup) { - removeChild((ParticleSystem *)_children->objectAtIndex(index),doCleanup); + removeChild((ParticleSystem *)_children->getObjectAtIndex(index),doCleanup); } void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index be7447fc4b..5d4859c34e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -989,7 +989,7 @@ void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int fra CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found"); - AnimationFrame* frame = static_cast( a->getFrames()->objectAtIndex(frameIndex) ); + AnimationFrame* frame = static_cast( a->getFrames()->getObjectAtIndex(frameIndex) ); CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame"); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index a79feb2402..de63c8f81b 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -226,7 +226,7 @@ void SpriteBatchNode::removeChild(Node *child, bool cleanup) void SpriteBatchNode::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup) { - removeChild((Sprite*)(_children->objectAtIndex(uIndex)), bDoCleanup); + removeChild((Sprite*)(_children->getObjectAtIndex(uIndex)), bDoCleanup); } void SpriteBatchNode::removeAllChildrenWithCleanup(bool bCleanup) @@ -470,7 +470,7 @@ unsigned int SpriteBatchNode::highestAtlasIndexInChild(Sprite *pSprite) } else { - return highestAtlasIndexInChild((Sprite*)(children->lastObject())); + return highestAtlasIndexInChild((Sprite*)(children->getLastObject())); } } @@ -484,14 +484,14 @@ unsigned int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *pSprite) } else { - return lowestAtlasIndexInChild((Sprite*)(children->objectAtIndex(0))); + return lowestAtlasIndexInChild((Sprite*)(children->getObjectAtIndex(0))); } } unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) { Array *pBrothers = sprite->getParent()->getChildren(); - unsigned int uChildIndex = pBrothers->indexOfObject(sprite); + unsigned int uChildIndex = pBrothers->getIndexOfObject(sprite); // ignore parent Z if parent is spriteSheet bool bIgnoreParent = (SpriteBatchNode*)(sprite->getParent()) == this; @@ -499,7 +499,7 @@ unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) if (uChildIndex > 0 && uChildIndex < UINT_MAX) { - pPrevious = (Sprite*)(pBrothers->objectAtIndex(uChildIndex - 1)); + pPrevious = (Sprite*)(pBrothers->getObjectAtIndex(uChildIndex - 1)); } // first child of the sprite sheet @@ -622,7 +622,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) // Cleanup sprite. It might be reused (issue #569) sprite->setBatchNode(NULL); - unsigned int uIndex = _descendants->indexOfObject(sprite); + unsigned int uIndex = _descendants->getIndexOfObject(sprite); if (uIndex != UINT_MAX) { _descendants->removeObjectAtIndex(uIndex); @@ -632,7 +632,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) for(; uIndex < count; ++uIndex) { - Sprite* s = (Sprite*)(_descendants->objectAtIndex(uIndex)); + Sprite* s = (Sprite*)(_descendants->getObjectAtIndex(uIndex)); s->setAtlasIndex( s->getAtlasIndex() - 1 ); } } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index f1f3bc7f14..940b3557e6 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -332,7 +332,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) { - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); int tilesAmount = layerSize.width*layerSize.height; @@ -366,7 +366,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else { - TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); + TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject(); Dictionary *dict = new Dictionary(); pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict))); pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); @@ -427,7 +427,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if (elementName == "image") { - TMXTilesetInfo* tileset = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); + TMXTilesetInfo* tileset = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject(); // build full path std::string imagename = valueForKey("source", attributeDict); @@ -451,7 +451,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { pTMXMapInfo->setLayerAttribs(pTMXMapInfo->getLayerAttribs() | TMXLayerAttribNone); - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width*layerSize.height; @@ -497,7 +497,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if (elementName == "object") { char buffer[32] = {0}; - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); // The value for "type" was blank or not a valid class name // Create an instance of TMXObjectInfo to store the object and its properties @@ -569,7 +569,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyLayer ) { // The parent element is the last layer - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); String *value = new String(valueForKey("value", attributeDict)); std::string key = valueForKey("name", attributeDict); // Add the property to the layer @@ -580,7 +580,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyObjectGroup ) { // The parent element is the last object group - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); String *value = new String(valueForKey("value", attributeDict)); const char* key = valueForKey("name", attributeDict); objectGroup->getProperties()->setObject(value, key); @@ -590,8 +590,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyObject ) { // The parent element is the last object - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); - Dictionary* dict = (Dictionary*)objectGroup->getObjects()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); + Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject(); const char* propertyName = valueForKey("name", attributeDict); String *propertyValue = new String(valueForKey("value", attributeDict)); @@ -611,8 +611,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if (elementName == "polygon") { // find parent object's dict and add polygon-points to it - TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->lastObject(); - Dictionary* dict = (Dictionary*)objectGroup->getObjects()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->getLastObject(); + Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject(); // get points value string const char* value = valueForKey("points", attributeDict); @@ -690,7 +690,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name) { pTMXMapInfo->setStoringCharacters(false); - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); std::string currentString = pTMXMapInfo->getCurrentString(); unsigned char *buffer; @@ -733,7 +733,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name) } else if (pTMXMapInfo->getLayerAttribs() & TMXLayerAttribNone) { - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width * layerSize.height; diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 8d070abba4..67c7a619b0 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ #include "CCTouchDispatcher.h" + +#include #include "CCTouchHandler.h" #include "cocoa/CCArray.h" #include "cocoa/CCSet.h" @@ -31,14 +33,13 @@ THE SOFTWARE. #include "textures/CCTexture2D.h" #include "support/data_support/ccCArray.h" #include "ccMacros.h" -#include NS_CC_BEGIN /** * Used for sort */ -#if 0 +#if CC_USE_ARRAY_VECTOR static int less(const RCPtr& p1, const RCPtr& p2) { Object *o1, *o2; @@ -306,8 +307,8 @@ TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelega void TouchDispatcher::rearrangeHandlers(Array *array) { - std::sort(array->data->arr, array->data->arr + array->data->num, less); -// std::sort( std::begin(*array), std::end(*array), less); +// std::sort(array->data->arr, array->data->arr + array->data->num, less); + std::sort( std::begin(*array), std::end(*array), less); } void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate) diff --git a/extensions/CCArmature/CCBone.cpp b/extensions/CCArmature/CCBone.cpp index ea0c8dca29..4361339ed9 100644 --- a/extensions/CCArmature/CCBone.cpp +++ b/extensions/CCArmature/CCBone.cpp @@ -230,7 +230,7 @@ void Bone::addChildBone(Bone *child) childrenAlloc(); } - if (_children->indexOfObject(child) == UINT_MAX) + if (_children->getIndexOfObject(child) == UINT_MAX) { _children->addObject(child); child->setParentBone(this); @@ -239,7 +239,7 @@ void Bone::addChildBone(Bone *child) void Bone::removeChildBone(Bone *bone, bool recursion) { - if ( _children->indexOfObject(bone) != UINT_MAX ) + if ( _children->getIndexOfObject(bone) != UINT_MAX ) { if(recursion) { diff --git a/extensions/CCArmature/datas/CCDatas.cpp b/extensions/CCArmature/datas/CCDatas.cpp index 9966d9fbe0..ba50cb80d0 100644 --- a/extensions/CCArmature/datas/CCDatas.cpp +++ b/extensions/CCArmature/datas/CCDatas.cpp @@ -224,7 +224,7 @@ void BoneData::addDisplayData(DisplayData *displayData) DisplayData *BoneData::getDisplayData(int index) { - return (DisplayData *)displayDataList.objectAtIndex(index); + return (DisplayData *)displayDataList.getObjectAtIndex(index); } ArmatureData::ArmatureData() @@ -301,7 +301,7 @@ void MovementBoneData::addFrameData(FrameData *frameData) FrameData *MovementBoneData::getFrameData(int index) { - return (FrameData *)frameList.objectAtIndex(index); + return (FrameData *)frameList.getObjectAtIndex(index); } @@ -406,7 +406,7 @@ void TextureData::addContourData(ContourData *contourData) ContourData *TextureData::getContourData(int index) { - return (ContourData *)contourDataList.objectAtIndex(index); + return (ContourData *)contourDataList.getObjectAtIndex(index); } diff --git a/extensions/CCArmature/display/CCDisplayManager.cpp b/extensions/CCArmature/display/CCDisplayManager.cpp index 7fd43f82c8..3fa223629a 100644 --- a/extensions/CCArmature/display/CCDisplayManager.cpp +++ b/extensions/CCArmature/display/CCDisplayManager.cpp @@ -92,7 +92,7 @@ void DisplayManager::addDisplay(DisplayData *displayData, int index) if(index >= 0 && (unsigned int)index < _decoDisplayList->count()) { - decoDisplay = (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index); + decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } else { @@ -145,7 +145,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force) } - DecorativeDisplay *decoDisplay = (DecorativeDisplay *)_decoDisplayList->objectAtIndex(_displayIndex); + DecorativeDisplay *decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(_displayIndex); setCurrentDecorativeDisplay(decoDisplay); } @@ -210,7 +210,7 @@ DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay() DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index) { - return (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index); + return (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } void DisplayManager::initDisplayList(BoneData *boneData) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 653aee289d..cfbe82bd0b 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -372,12 +372,12 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get position type Array *array = static_cast(getBaseValue(pNode, propName)); - CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative position Array *value = static_cast(pKeyframe1->getValue()); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); Size containerSize = getContainerSize(pNode->getParent()); @@ -389,12 +389,12 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get position type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative scale Array *value = (Array*)pKeyframe1->getValue(); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { @@ -409,8 +409,8 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get relative skew Array *value = (Array*)pKeyframe1->getValue(); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); return SkewTo::create(duration, x, y); } @@ -445,12 +445,12 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get position type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative position Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), propName)); } @@ -458,12 +458,12 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get scale type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative scale Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); setRelativeScale(pNode, x, y, type, propName); } @@ -471,8 +471,8 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get relative scale Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); pNode->setSkewX(x); pNode->setSkewY(y); @@ -537,7 +537,7 @@ void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqPr else { // Use first keyframe - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(0); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(0); setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), fTweenDuration); } } @@ -623,7 +623,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann for (int i = 0; i < numKeyframes; ++i) { - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(i); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { @@ -631,8 +631,8 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann } Array* keyVal = static_cast(keyframe->getValue()); - std::string selectorName = static_cast(keyVal->objectAtIndex(0))->getCString(); - CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast(keyVal->objectAtIndex(1))->getCString()); + std::string selectorName = static_cast(keyVal->getObjectAtIndex(0))->getCString(); + CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast(keyVal->getObjectAtIndex(1))->getCString()); if(_jsControlled) { String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str()); @@ -696,7 +696,7 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) for (int i = 0; i < numKeyframes; ++i) { - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(i); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { @@ -705,18 +705,18 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) stringstream ss (stringstream::in | stringstream::out); Array* keyVal = (Array*)keyframe->getValue(); - std::string soundFile = ((String *)keyVal->objectAtIndex(0))->getCString(); + std::string soundFile = ((String *)keyVal->getObjectAtIndex(0))->getCString(); float pitch, pan, gain; - ss << ((String *)keyVal->objectAtIndex(1))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(1))->getCString(); ss >> pitch; ss.flush(); - ss << ((String *)keyVal->objectAtIndex(2))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(2))->getCString(); ss >> pan; ss.flush(); - ss << ((String *)keyVal->objectAtIndex(3))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(3))->getCString(); ss >> gain; ss.flush(); @@ -740,7 +740,7 @@ void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, // Make an animation! Array *actions = Array::create(); - CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->objectAtIndex(0); + CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->getObjectAtIndex(0); float timeFirst = keyframeFirst->getTime() + fTweenDuration; if (timeFirst > 0) @@ -750,8 +750,8 @@ void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, for (int i = 0; i < numKeyframes - 1; ++i) { - CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->objectAtIndex(i); - CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->objectAtIndex(i+1); + CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->getObjectAtIndex(i); + CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->getObjectAtIndex(i+1); ActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); if (action) diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 2c6ec045f8..666286ea80 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -967,8 +967,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader for (int i = 0 ; i < nCount; i++) { - pCCBReader->addOwnerCallbackName((dynamic_cast(ownerCallbackNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNodes->objectAtIndex(i)) ); + pCCBReader->addOwnerCallbackName((dynamic_cast(ownerCallbackNames->getObjectAtIndex(i)))->getCString()); + pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNodes->getObjectAtIndex(i)) ); } } //set variables @@ -982,8 +982,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader for (int i = 0 ; i < nCount; i++) { - pCCBReader->addOwnerOutletName((static_cast(ownerOutletNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerOutletNode(static_cast(ownerOutletNodes->objectAtIndex(i))); + pCCBReader->addOwnerOutletName((static_cast(ownerOutletNames->getObjectAtIndex(i)))->getCString()); + pCCBReader->addOwnerOutletNode(static_cast(ownerOutletNodes->getObjectAtIndex(i))); } } } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index f4270a37b1..94fa238c02 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -628,11 +628,11 @@ bool ScrollView::ccTouchBegan(Touch* touch, Event* event) } else if (_touches->count() == 2) { - _touchPoint = (this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getMidpoint( - this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1)))); + _touchPoint = (this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getMidpoint( + this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1)))); - _touchLength = _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getDistance( - _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1))); + _touchLength = _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getDistance( + _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1))); _dragging = false; } @@ -656,7 +656,7 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) frame = getViewRect(); - newPoint = this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)); + newPoint = this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)); moveDistance = newPoint - _touchPoint; float dis = 0.0f; @@ -713,8 +713,8 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) } else if (_touches->count() == 2 && !_dragging) { - const float len = _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getDistance( - _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1))); + const float len = _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getDistance( + _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1))); this->setZoomScale(this->getZoomScale()*len/_touchLength); } } diff --git a/extensions/GUI/CCScrollView/CCSorting.cpp b/extensions/GUI/CCScrollView/CCSorting.cpp index 7a82b768b4..19513d25f0 100644 --- a/extensions/GUI/CCScrollView/CCSorting.cpp +++ b/extensions/GUI/CCScrollView/CCSorting.cpp @@ -80,7 +80,7 @@ void ArrayForObjectSorting::removeSortedObject(SortableObject* object) idx = this->indexOfSortedObject(object); if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); if(foundObj->getObjectID() == object->getObjectID()) { this->removeObjectAtIndex(idx); @@ -96,7 +96,7 @@ void ArrayForObjectSorting::setObjectID_ofSortedObject(unsigned int tag, Sortabl idx = this->indexOfSortedObject(object); if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); Object* pObj = dynamic_cast(foundObj); pObj->retain(); @@ -130,7 +130,7 @@ SortableObject* ArrayForObjectSorting::objectWithObjectID(unsigned int tag) if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); if (foundObj->getObjectID() != tag) { foundObj = NULL; } diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 6e74419e3f..f8b903bd84 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -190,7 +190,7 @@ void TableView::insertCellAtIndex(unsigned int idx) newIdx = _cellsUsed->indexOfSortedObject(cell); for (unsigned int i=newIdx; i<_cellsUsed->count(); i++) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(i); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(i); this->_setIndexForCell(cell->getIdx()+1, cell); } } @@ -237,7 +237,7 @@ void TableView::removeCellAtIndex(unsigned int idx) // [_indices shiftIndexesStartingAtIndex:idx+1 by:-1]; for (unsigned int i=_cellsUsed->count()-1; i > newIdx; i--) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(i); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(i); this->_setIndexForCell(cell->getIdx()-1, cell); } } @@ -249,7 +249,7 @@ TableViewCell *TableView::dequeueCell() if (_cellsFreed->count() == 0) { cell = NULL; } else { - cell = (TableViewCell*)_cellsFreed->objectAtIndex(0); + cell = (TableViewCell*)_cellsFreed->getObjectAtIndex(0); cell->retain(); _cellsFreed->removeObjectAtIndex(0); cell->autorelease(); @@ -513,7 +513,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) if (_cellsUsed->count() > 0) { - TableViewCell* cell = (TableViewCell*)_cellsUsed->objectAtIndex(0); + TableViewCell* cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(0); idx = cell->getIdx(); while(idx _moveCellOutOfSight(cell); if (_cellsUsed->count() > 0) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(0); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(0); idx = cell->getIdx(); } else @@ -532,7 +532,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) } if (_cellsUsed->count() > 0) { - TableViewCell *cell = (TableViewCell*)_cellsUsed->lastObject(); + TableViewCell *cell = (TableViewCell*)_cellsUsed->getLastObject(); idx = cell->getIdx(); while(idx <= maxIdx && idx > endIdx) @@ -540,7 +540,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) this->_moveCellOutOfSight(cell); if (_cellsUsed->count() > 0) { - cell = (TableViewCell*)_cellsUsed->lastObject(); + cell = (TableViewCell*)_cellsUsed->getLastObject(); idx = cell->getIdx(); } diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 17c9f2057c..025f058e99 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -114,7 +114,7 @@ static void networkThread(void) if (0 != s_requestQueue->count()) { - request = dynamic_cast(s_requestQueue->objectAtIndex(0)); + request = dynamic_cast(s_requestQueue->getObjectAtIndex(0)); s_requestQueue->removeObjectAtIndex(0); } @@ -485,7 +485,7 @@ void HttpClient::dispatchResponseCallbacks(float delta) if (s_responseQueue->count()) { - response = dynamic_cast(s_responseQueue->objectAtIndex(0)); + response = dynamic_cast(s_responseQueue->getObjectAtIndex(0)); s_responseQueue->removeObjectAtIndex(0); } diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index 54589542f8..70cfa52f94 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -1649,7 +1649,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) { CCLOG("remove random system"); unsigned int uRand = rand() % (nChildrenCount - 1); - _batchNode->removeChild((Node*)_batchNode->getChildren()->objectAtIndex(uRand), true); + _batchNode->removeChild((Node*)_batchNode->getChildren()->getObjectAtIndex(uRand), true); auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); //add new @@ -1796,7 +1796,7 @@ void ReorderParticleSystems::onEnter() void ReorderParticleSystems::reorderSystem(float time) { - auto system = (ParticleSystem*)_batchNode->getChildren()->objectAtIndex(1); + auto system = (ParticleSystem*)_batchNode->getChildren()->getObjectAtIndex(1); _batchNode->reorderChild(system, system->getZOrder() - 1); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index e9fba85928..b1e79e3912 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -445,7 +445,7 @@ void AddSpriteSheet::update(float dt) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), zs[i], kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), zs[i], kTagBase+i); } batchNode->sortAllChildren(); @@ -503,7 +503,7 @@ void RemoveSpriteSheet::update(float dt) // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); } // remove them @@ -559,7 +559,7 @@ void ReorderSpriteSheet::update(float dt) // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); } batchNode->sortAllChildren(); @@ -569,7 +569,7 @@ void ReorderSpriteSheet::update(float dt) for( int i=0;i < totalToAdd;i++) { - auto node = (Node*) (batchNode->getChildren()->objectAtIndex(i)); + auto node = (Node*) (batchNode->getChildren()->getObjectAtIndex(i)); batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); } diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 6dd751cebb..adcf29b25a 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -6b5ddb2c8e2b4b8dea01e8ff068ff9a15795db69 \ No newline at end of file +7b8ff30c1fc482c4d7485032c73c1145a60168b4 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp index b373f5223f..e83c86c9cd 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp @@ -166,7 +166,7 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in Point pos; for (int i = 0; i < count; ++i) { - node = (Node*)children->objectAtIndex(i); + node = (Node*)children->getObjectAtIndex(i); pos = node->getPosition(); pos.y += adjustVert; node->setPosition(pos); diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 33d403fdfa..bac1593fe1 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -722,8 +722,8 @@ void ScriptingCore::pauseSchedulesAndActions(js_proxy_t* p) Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { - if (arr->objectAtIndex(i)) { - node->getScheduler()->pauseTarget(arr->objectAtIndex(i)); + if (arr->getObjectAtIndex(i)) { + node->getScheduler()->pauseTarget(arr->getObjectAtIndex(i)); } } } @@ -736,8 +736,8 @@ void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { - if (!arr->objectAtIndex(i)) continue; - node->getScheduler()->resumeTarget(arr->objectAtIndex(i)); + if (!arr->getObjectAtIndex(i)) continue; + node->getScheduler()->resumeTarget(arr->getObjectAtIndex(i)); } } diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 04f83fd48c..dbf188c465 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -69358d388dd779c6334c786e53ea14243bfde00b \ No newline at end of file +d4944c285d6219a01aa06f326168ae67d08b9cb0 \ No newline at end of file