From 917bd8c3d94537427843227c938677801e128f2e Mon Sep 17 00:00:00 2001 From: youyou <501251991@qq.com> Date: Fri, 13 Dec 2013 19:40:38 +0800 Subject: [PATCH] change Array to Vector --- .../editor-support/cocostudio/CCArmature.cpp | 20 +++---- .../cocostudio/CCArmatureAnimation.cpp | 4 +- .../cocostudio/CCColliderDetector.cpp | 29 ++++------ .../cocostudio/CCColliderDetector.h | 8 +-- .../cocostudio/CCDataReaderHelper.cpp | 54 +++++++++---------- cocos/editor-support/cocostudio/CCDatas.cpp | 40 +++++++------- cocos/editor-support/cocostudio/CCDatas.h | 27 +++------- .../cocostudio/CCDisplayFactory.cpp | 4 +- cocos/editor-support/cocostudio/CCTween.cpp | 18 +++---- .../CocoStudioArmatureTest/ArmatureScene.cpp | 18 +++---- .../CocoStudioArmatureTest/ArmatureScene.h | 2 +- 11 files changed, 99 insertions(+), 125 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 64577e4b2a..250ce68375 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -156,22 +156,18 @@ bool Armature::init(const char *name) _armatureData = armatureData; - - DictElement *_element = nullptr; - Dictionary *boneDataDic = &armatureData->boneDataDic; - CCDICT_FOREACH(boneDataDic, _element) + for (auto element : armatureData->boneDataDic) { - Bone *bone = createBone(_element->getStrKey()); + Bone *bone = createBone(element.first.c_str()); //! init bone's Tween to 1st movement's 1st frame do { - MovementData *movData = animationData->getMovement(animationData->movementNames.at(0).c_str()); CC_BREAK_IF(!movData); MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str()); - CC_BREAK_IF(!movBoneData || movBoneData->frameList.count() <= 0); + CC_BREAK_IF(!movBoneData || movBoneData->frameList.size() <= 0); FrameData *frameData = movBoneData->getFrameData(0); CC_BREAK_IF(!frameData); @@ -713,15 +709,15 @@ void CCArmature::drawContour() for (auto object : *bodyList) { ColliderBody *body = static_cast(object); - Array *vertexList = body->getCalculatedVertexList(); + const std::vector &vertexList = body->getCalculatedVertexList(); - int length = vertexList->count(); + int length = vertexList.size(); Point *points = new Point[length]; for (int i = 0; i(vertexList->getObjectAtIndex(i)); - points[i].x = vertex->x; - points[i].y = vertex->y; + CCPoint p = vertexList.at(i); + points[i].x = p.x; + points[i].y = p.y; } DrawPrimitives::drawPoly( points, length, true ); diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index bf3e2381ae..8cd49df564 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -218,10 +218,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura CCDICT_FOREACH(dict, element) { Bone *bone = static_cast(element->getObject()); - movementBoneData = static_cast(_movementData->movBoneDataDic.objectForKey(bone->getName())); + movementBoneData = static_cast(_movementData->movBoneDataDic.at(bone->getName())); Tween *tween = bone->getTween(); - if(movementBoneData && movementBoneData->frameList.count() > 0) + if(movementBoneData && movementBoneData->frameList.size() > 0) { _tweenList->addObject(tween); movementBoneData->duration = _movementData->duration; diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.cpp b/cocos/editor-support/cocostudio/CCColliderDetector.cpp index 72f57ad8ec..6adf468cdd 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.cpp +++ b/cocos/editor-support/cocostudio/CCColliderDetector.cpp @@ -96,9 +96,6 @@ ColliderBody::ColliderBody(ContourData *contourData) : _contourData(contourData) { CC_SAFE_RETAIN(_contourData); - - _calculatedVertexList = Array::create(); - CC_SAFE_RETAIN(_calculatedVertexList); } #endif @@ -108,8 +105,6 @@ ColliderBody::~ColliderBody() #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT CC_SAFE_DELETE(_filter); -#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - CC_SAFE_RELEASE(_calculatedVertexList); #endif } @@ -199,23 +194,21 @@ void ColliderDetector::addContourData(ContourData *contourData) #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - Array *calculatedVertexList = colliderBody->getCalculatedVertexList(); + std::vector &calculatedVertexList = colliderBody->_calculatedVertexList; int num = contourData->vertexList.size(); for (int i = 0; i < num; i++) { - ContourVertex2 *newVertex = new ContourVertex2(0, 0); - calculatedVertexList->addObject(newVertex); - newVertex->release(); + calculatedVertexList.push_back(Point()); } #endif } -void ColliderDetector::addContourDataList(Array *contourDataList) +void ColliderDetector::addContourDataList(cocos2d::Vector &contourDataList) { - for(auto object : *contourDataList) + for(auto object : contourDataList) { - addContourData((ContourData *)object); + addContourData(object); } } @@ -365,22 +358,22 @@ void ColliderDetector::updateTransform(AffineTransform &t) } #endif - int num = contourData->vertexList.count(); - ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr; + int num = contourData->vertexList.size(); + std::vector &vs = contourData->vertexList; #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - ContourVertex2 **cvs = (ContourVertex2 **)colliderBody->getCalculatedVertexList()->data->arr; + std::vector &cvs = colliderBody->_calculatedVertexList; #endif for (int i = 0; i < num; i++) { - helpPoint.setPoint( vs[i]->x, vs[i]->y); + helpPoint.setPoint( vs.at(i).x, vs.at(i).y); helpPoint = PointApplyAffineTransform(helpPoint, t); #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - cvs[i]->x = helpPoint.x; - cvs[i]->y = helpPoint.y; + cvs.at(i).x = helpPoint.x; + cvs.at(i).y = helpPoint.y; #endif #if ENABLE_PHYSICS_BOX2D_DETECT diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index 14680f7305..fc87eb5221 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -105,7 +105,7 @@ public: virtual void setShape(cpShape *shape) { _shape = shape; } virtual cpShape *getShape() const { return _shape; } #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - virtual cocos2d::Array *getCalculatedVertexList() const { return _calculatedVertexList; } + virtual const std::vector &getCalculatedVertexList() const { return _calculatedVertexList; } #endif private: @@ -117,10 +117,12 @@ private: cpShape *_shape; ColliderFilter *_filter; #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - cocos2d::Array *_calculatedVertexList; + std::vector _calculatedVertexList; #endif ContourData *_contourData; + + friend class ColliderDetector; }; /* @@ -148,7 +150,7 @@ public: virtual bool init(Bone *bone); void addContourData(ContourData *contourData); - void addContourDataList(cocos2d::Array *contourDataList); + void addContourDataList(cocos2d::Vector &contourDataList); void removeContourData(ContourData *contourData); void removeAll(); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index f5fd3a47c5..d597de1e06 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -886,24 +886,24 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov frameXML = frameXML->NextSiblingElement(FRAME); } - + //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - FrameData **frames = (FrameData **)movBoneData->frameList.data->arr; - for (int j = movBoneData->frameList.count() - 1; j >= 0; j--) + cocos2d::Vector &frames = movBoneData->frameList; + for (int j = movBoneData->frameList.size() - 1; j >= 0; j--) { if (j > 0) { - float difSkewX = frames[j]->skewX - frames[j - 1]->skewX; - float difSkewY = frames[j]->skewY - frames[j - 1]->skewY; + float difSkewX = frames.at(j)->skewX - frames.at(j-1)->skewX; + float difSkewY = frames.at(j)->skewY - frames.at(j-1)->skewY; if (difSkewX < -M_PI || difSkewX > M_PI) { - frames[j - 1]->skewX = difSkewX < 0 ? frames[j - 1]->skewX - 2 * M_PI : frames[j - 1]->skewX + 2 * M_PI; + frames.at(j-1)->skewX = difSkewX < 0 ? frames.at(j-1)->skewX - 2 * M_PI : frames.at(j-1)->skewX + 2 * M_PI; } if (difSkewY < -M_PI || difSkewY > M_PI) { - frames[j - 1]->skewY = difSkewY < 0 ? frames[j - 1]->skewY - 2 * M_PI : frames[j - 1]->skewY + 2 * M_PI; + frames.at(j-1)->skewY = difSkewY < 0 ? frames.at(j-1)->skewY - 2 * M_PI : frames.at(j-1)->skewY + 2 * M_PI; } } } @@ -911,7 +911,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov // FrameData *frameData = new FrameData(); - frameData->copy((FrameData *)movBoneData->frameList.getLastObject()); + frameData->copy((FrameData *)movBoneData->frameList.back()); frameData->frameID = movBoneData->duration; movBoneData->addFrameData(frameData); frameData->release(); @@ -1168,14 +1168,13 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D while (vertexDataXML) { - ContourVertex2 *vertex = new ContourVertex2(0, 0); - vertex->release(); + Point vertex; - vertexDataXML->QueryFloatAttribute(A_X, &vertex->x); - vertexDataXML->QueryFloatAttribute(A_Y, &vertex->y); + vertexDataXML->QueryFloatAttribute(A_X, &vertex.x); + vertexDataXML->QueryFloatAttribute(A_Y, &vertex.y); - vertex->y = -vertex->y; - contourData->vertexList.addObject(vertex); + vertex.y = -vertex.y; + contourData->vertexList.push_back(vertex); vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX); } @@ -1514,22 +1513,22 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - FrameData **frames = (FrameData **)movementBoneData->frameList.data->arr; - for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--) + cocos2d::Vector &frames = movementBoneData->frameList; + for (int i = frames.size() - 1; i >= 0; i--) { if (i > 0) { - float difSkewX = frames[i]->skewX - frames[i - 1]->skewX; - float difSkewY = frames[i]->skewY - frames[i - 1]->skewY; + float difSkewX = frames.at(i)->skewX - frames.at(i-1)->skewX; + float difSkewY = frames.at(i)->skewY - frames.at(i-1)->skewY; if (difSkewX < -M_PI || difSkewX > M_PI) { - frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI; + frames.at(i-1)->skewX = difSkewX < 0 ? frames.at(i-1)->skewX - 2 * M_PI : frames.at(i-1)->skewX + 2 * M_PI; } if (difSkewY < -M_PI || difSkewY > M_PI) { - frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI; + frames.at(i-1)->skewY = difSkewY < 0 ? frames.at(i-1)->skewY - 2 * M_PI : frames.at(i-1)->skewY + 2 * M_PI; } } } @@ -1537,10 +1536,10 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat if (dataInfo->cocoStudioVersion < VERSION_COMBINED) { - if (movementBoneData->frameList.count() > 0) + if (movementBoneData->frameList.size() > 0) { FrameData *frameData = new FrameData(); - frameData->copy((FrameData *)movementBoneData->frameList.getLastObject()); + frameData->copy((FrameData *)movementBoneData->frameList.back()); movementBoneData->addFrameData(frameData); frameData->release(); @@ -1614,7 +1613,7 @@ TextureData *DataReaderHelper::decodeTexture(JsonDictionary &json) { JsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i); ContourData *contourData = decodeContour(*dic); - textureData->contourDataList.addObject(contourData); + textureData->contourDataList.pushBack(contourData); contourData->release(); delete dic; @@ -1633,13 +1632,12 @@ ContourData *DataReaderHelper::decodeContour(JsonDictionary &json) { JsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i); - ContourVertex2 *vertex = new ContourVertex2(0, 0); + Point vertex; - vertex->x = dic->getItemFloatValue(A_X, 0); - vertex->y = dic->getItemFloatValue(A_Y, 0); + vertex.x = dic->getItemFloatValue(A_X, 0); + vertex.y = dic->getItemFloatValue(A_Y, 0); - contourData->vertexList.addObject(vertex); - vertex->release(); + contourData->vertexList.push_back(vertex); delete dic; } diff --git a/cocos/editor-support/cocostudio/CCDatas.cpp b/cocos/editor-support/cocostudio/CCDatas.cpp index 28c094e318..7f2a4d87d0 100644 --- a/cocos/editor-support/cocostudio/CCDatas.cpp +++ b/cocos/editor-support/cocostudio/CCDatas.cpp @@ -208,18 +208,17 @@ BoneData::~BoneData(void) bool BoneData::init() { - displayDataList.init(); return true; } void BoneData::addDisplayData(DisplayData *displayData) { - displayDataList.addObject(displayData); + displayDataList.pushBack(displayData); } DisplayData *BoneData::getDisplayData(int index) { - return static_cast(displayDataList.getObjectAtIndex(index)); + return static_cast(displayDataList.at(index)); } @@ -239,12 +238,12 @@ bool ArmatureData::init() void ArmatureData::addBoneData(BoneData *boneData) { - boneDataDic.setObject(boneData, boneData->name); + boneDataDic.insert(boneData->name, boneData); } BoneData *ArmatureData::getBoneData(const char *boneName) { - return static_cast(boneDataDic.objectForKey(boneName)); + return static_cast(boneDataDic.at(boneName)); } FrameData::FrameData(void) @@ -309,17 +308,17 @@ MovementBoneData::~MovementBoneData(void) bool MovementBoneData::init() { - return frameList.init(); + return true; } void MovementBoneData::addFrameData(FrameData *frameData) { - frameList.addObject(frameData); + frameList.pushBack(frameData); } FrameData *MovementBoneData::getFrameData(int index) { - return static_cast(frameList.getObjectAtIndex(index)); + return static_cast(frameList.at(index)); } @@ -341,12 +340,12 @@ MovementData::~MovementData(void) void MovementData::addMovementBoneData(MovementBoneData *movBoneData) { - movBoneDataDic.setObject(movBoneData, movBoneData->name); + movBoneDataDic.insert(movBoneData->name, movBoneData); } MovementBoneData *MovementData::getMovementBoneData(const char *boneName) { - return static_cast(movBoneDataDic.objectForKey(boneName)); + return static_cast(movBoneDataDic.at(boneName)); } @@ -361,18 +360,18 @@ AnimationData::~AnimationData(void) void AnimationData::addMovement(MovementData *movData) { - movementDataDic.setObject(movData, movData->name); + movementDataDic.insert(movData->name, movData); movementNames.push_back(movData->name); } MovementData *AnimationData::getMovement(const char *movementName) { - return static_cast(movementDataDic.objectForKey(movementName)); + return static_cast(movementDataDic.at(movementName)); } int AnimationData::getMovementCount() { - return movementDataDic.count(); + return movementDataDic.size(); } @@ -387,15 +386,12 @@ ContourData::~ContourData() bool ContourData::init() { - return vertexList.init(); + return true; } -void ContourData::addVertex(Point *vertex) +void ContourData::addVertex(Point &vertex) { - ContourVertex2 *vertex2 = new ContourVertex2(vertex->x, vertex->y); - vertex2->autorelease(); - - vertexList.addObject(vertex2); + vertexList.push_back(vertex); } TextureData::TextureData() @@ -413,17 +409,17 @@ TextureData::~TextureData() bool TextureData::init() { - return contourDataList.init(); + return true; } void TextureData::addContourData(ContourData *contourData) { - contourDataList.addObject(contourData); + contourDataList.pushBack(contourData); } ContourData *TextureData::getContourData(int index) { - return static_cast(contourDataList.getObjectAtIndex(index)); + return static_cast(contourDataList.at(index)); } diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 32d61b4ffb..eac9325a28 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -250,7 +250,7 @@ public: public: std::string name; //! the bone's name std::string parentName; //! the bone parent's name - cocos2d::Array displayDataList; //! save DisplayData informations for the Bone + cocos2d::Vector displayDataList; //! save DisplayData informations for the Bone cocos2d::AffineTransform boneDataTransform; }; @@ -282,7 +282,7 @@ public: BoneData *getBoneData(const char *boneName); public: std::string name; - cocos2d::Dictionary boneDataDic; + cocos2d::Map boneDataDic; float dataVersion; }; @@ -380,7 +380,7 @@ public: float duration; //! this Bone in this movement will last m_iDuration frames std::string name; //! bone name - cocos2d::Array frameList; + cocos2d::Vector frameList; }; /** @@ -438,7 +438,7 @@ public: * @key const char * * @value MovementBoneData * */ - cocos2d::Dictionary movBoneDataDic; + cocos2d::Map movBoneDataDic; }; @@ -469,22 +469,11 @@ public: int getMovementCount(); public: std::string name; - cocos2d::Dictionary movementDataDic; + cocos2d::Map movementDataDic; std::vector movementNames; }; -struct ContourVertex2 : public cocos2d::Object -{ - ContourVertex2(float xx, float yy) - { - this->x = xx; - this->y = yy; - } - - float x; - float y; -}; /* * ContourData include a contour vertex information @@ -507,9 +496,9 @@ public: ~ContourData(void); virtual bool init(); - virtual void addVertex(cocos2d::Point *vertex); + virtual void addVertex(cocos2d::Point &vertex); public: - cocos2d::Array vertexList; //! Save contour vertex info, vertex saved in a Point + std::vector vertexList; //! Save contour vertex info, vertex saved in a Point }; @@ -549,7 +538,7 @@ public: std::string name; //! The texture's name - cocos2d::Array contourDataList; + cocos2d::Vector contourDataList; }; diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index 793988cf40..92b46c7e7a 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -204,12 +204,12 @@ void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDispla #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX - if (textureData && textureData->contourDataList.count() > 0) + if (textureData && textureData->contourDataList.size() > 0) { //! create ContourSprite ColliderDetector *colliderDetector = ColliderDetector::create(bone); - colliderDetector->addContourDataList(&textureData->contourDataList); + colliderDetector->addContourDataList(textureData->contourDataList); decoDisplay->setColliderDetector(colliderDetector); } diff --git a/cocos/editor-support/cocostudio/CCTween.cpp b/cocos/editor-support/cocostudio/CCTween.cpp index 44b8f1b4ab..3dae96b109 100644 --- a/cocos/editor-support/cocostudio/CCTween.cpp +++ b/cocos/editor-support/cocostudio/CCTween.cpp @@ -141,7 +141,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio } _frameTweenEasing = Linear; } - else if (_movementBoneData->frameList.count() > 1) + else if (_movementBoneData->frameList.size() > 1) { _durationTween = durationTween * _movementBoneData->scale; @@ -404,25 +404,25 @@ float Tween::updateFrameData(float currentPercent) * Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew. * _toIndex is next index will play */ - int length = _movementBoneData->frameList.count(); - FrameData **frames = (FrameData **)_movementBoneData->frameList.data->arr; + int length = _movementBoneData->frameList.size(); + cocos2d::Vector &frames = _movementBoneData->frameList; FrameData *from = nullptr; FrameData *to = nullptr; - if (playedTime < frames[0]->frameID) + if (playedTime < frames.at(0)->frameID) { - from = to = frames[0]; + from = to = frames.at(0); setBetween(from, to); return _currentPercent; } - if(playedTime >= frames[length - 1]->frameID) + if(playedTime >= frames.at(length - 1)->frameID) { // If _passLastFrame is true and playedTime >= frames[length - 1]->frameID, then do not need to go on. if (_passLastFrame) { - from = to = frames[length - 1]; + from = to = frames.at(length - 1); setBetween(from, to); return _currentPercent; } @@ -437,7 +437,7 @@ float Tween::updateFrameData(float currentPercent) do { _fromIndex = _toIndex; - from = frames[_fromIndex]; + from = frames.at(_fromIndex); _totalDuration = from->frameID; _toIndex = _fromIndex + 1; @@ -446,7 +446,7 @@ float Tween::updateFrameData(float currentPercent) _toIndex = 0; } - to = frames[_toIndex]; + to = frames.at(_toIndex); //! Guaranteed to trigger frame event if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent()) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 4d9c161bbb..3612bd8f80 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1040,24 +1040,24 @@ void TestColliderDetector::update(float delta) for (auto object : *bodyList) { ColliderBody *body = static_cast(object); - Array *vertexList = body->getCalculatedVertexList(); + const std::vector &vertexList = body->getCalculatedVertexList(); float minx, miny, maxx, maxy = 0; - int length = vertexList->count(); + int length = vertexList.size(); for (int i = 0; i(vertexList->getObjectAtIndex(i)); + Point vertex = vertexList.at(i); if (i == 0) { - minx = maxx = vertex->x; - miny = maxy = vertex->y; + minx = maxx = vertex.x; + miny = maxy = vertex.y; } else { - minx = vertex->x < minx ? vertex->x : minx; - miny = vertex->y < miny ? vertex->y : miny; - maxx = vertex->x > maxx ? vertex->x : maxx; - maxy = vertex->y > maxy ? vertex->y : maxy; + minx = vertex.x < minx ? vertex.x : minx; + miny = vertex.y < miny ? vertex.y : miny; + maxx = vertex.x > maxx ? vertex.x : maxx; + maxy = vertex.y > maxy ? vertex.y : maxy; } } Rect temp = Rect(minx, miny, maxx - minx, maxy - miny); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index df893946ef..4bca36bec1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -117,7 +117,7 @@ public: virtual void addArmature(int number); virtual void addArmatureToParent(cocostudio::Armature *armature); virtual void removeArmatureFromParent(int tag); - virtual void refreshTitile(); + virtual void refreshTitle(); int armatureCount;