change Array to Vector

This commit is contained in:
youyou 2013-12-13 19:40:38 +08:00
parent 0e8c3409e5
commit 917bd8c3d9
11 changed files with 99 additions and 125 deletions

View File

@ -156,22 +156,18 @@ bool Armature::init(const char *name)
_armatureData = armatureData; _armatureData = armatureData;
for (auto element : armatureData->boneDataDic)
DictElement *_element = nullptr;
Dictionary *boneDataDic = &armatureData->boneDataDic;
CCDICT_FOREACH(boneDataDic, _element)
{ {
Bone *bone = createBone(_element->getStrKey()); Bone *bone = createBone(element.first.c_str());
//! init bone's Tween to 1st movement's 1st frame //! init bone's Tween to 1st movement's 1st frame
do do
{ {
MovementData *movData = animationData->getMovement(animationData->movementNames.at(0).c_str()); MovementData *movData = animationData->getMovement(animationData->movementNames.at(0).c_str());
CC_BREAK_IF(!movData); CC_BREAK_IF(!movData);
MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str()); 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); FrameData *frameData = movBoneData->getFrameData(0);
CC_BREAK_IF(!frameData); CC_BREAK_IF(!frameData);
@ -713,15 +709,15 @@ void CCArmature::drawContour()
for (auto object : *bodyList) for (auto object : *bodyList)
{ {
ColliderBody *body = static_cast<ColliderBody*>(object); ColliderBody *body = static_cast<ColliderBody*>(object);
Array *vertexList = body->getCalculatedVertexList(); const std::vector<CCPoint> &vertexList = body->getCalculatedVertexList();
int length = vertexList->count(); int length = vertexList.size();
Point *points = new Point[length]; Point *points = new Point[length];
for (int i = 0; i<length; i++) for (int i = 0; i<length; i++)
{ {
ContourVertex2 *vertex = static_cast<ContourVertex2*>(vertexList->getObjectAtIndex(i)); CCPoint p = vertexList.at(i);
points[i].x = vertex->x; points[i].x = p.x;
points[i].y = vertex->y; points[i].y = p.y;
} }
DrawPrimitives::drawPoly( points, length, true ); DrawPrimitives::drawPoly( points, length, true );

View File

@ -218,10 +218,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
CCDICT_FOREACH(dict, element) CCDICT_FOREACH(dict, element)
{ {
Bone *bone = static_cast<Bone*>(element->getObject()); Bone *bone = static_cast<Bone*>(element->getObject());
movementBoneData = static_cast<MovementBoneData *>(_movementData->movBoneDataDic.objectForKey(bone->getName())); movementBoneData = static_cast<MovementBoneData *>(_movementData->movBoneDataDic.at(bone->getName()));
Tween *tween = bone->getTween(); Tween *tween = bone->getTween();
if(movementBoneData && movementBoneData->frameList.count() > 0) if(movementBoneData && movementBoneData->frameList.size() > 0)
{ {
_tweenList->addObject(tween); _tweenList->addObject(tween);
movementBoneData->duration = _movementData->duration; movementBoneData->duration = _movementData->duration;

View File

@ -96,9 +96,6 @@ ColliderBody::ColliderBody(ContourData *contourData)
: _contourData(contourData) : _contourData(contourData)
{ {
CC_SAFE_RETAIN(_contourData); CC_SAFE_RETAIN(_contourData);
_calculatedVertexList = Array::create();
CC_SAFE_RETAIN(_calculatedVertexList);
} }
#endif #endif
@ -108,8 +105,6 @@ ColliderBody::~ColliderBody()
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
CC_SAFE_DELETE(_filter); CC_SAFE_DELETE(_filter);
#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
CC_SAFE_RELEASE(_calculatedVertexList);
#endif #endif
} }
@ -199,23 +194,21 @@ void ColliderDetector::addContourData(ContourData *contourData)
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
Array *calculatedVertexList = colliderBody->getCalculatedVertexList(); std::vector<Point> &calculatedVertexList = colliderBody->_calculatedVertexList;
int num = contourData->vertexList.size(); int num = contourData->vertexList.size();
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
ContourVertex2 *newVertex = new ContourVertex2(0, 0); calculatedVertexList.push_back(Point());
calculatedVertexList->addObject(newVertex);
newVertex->release();
} }
#endif #endif
} }
void ColliderDetector::addContourDataList(Array *contourDataList) void ColliderDetector::addContourDataList(cocos2d::Vector<ContourData*> &contourDataList)
{ {
for(auto object : *contourDataList) for(auto object : contourDataList)
{ {
addContourData((ContourData *)object); addContourData(object);
} }
} }
@ -365,22 +358,22 @@ void ColliderDetector::updateTransform(AffineTransform &t)
} }
#endif #endif
int num = contourData->vertexList.count(); int num = contourData->vertexList.size();
ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr; std::vector<cocos2d::Point> &vs = contourData->vertexList;
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
ContourVertex2 **cvs = (ContourVertex2 **)colliderBody->getCalculatedVertexList()->data->arr; std::vector<cocos2d::Point> &cvs = colliderBody->_calculatedVertexList;
#endif #endif
for (int i = 0; i < num; i++) 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); helpPoint = PointApplyAffineTransform(helpPoint, t);
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
cvs[i]->x = helpPoint.x; cvs.at(i).x = helpPoint.x;
cvs[i]->y = helpPoint.y; cvs.at(i).y = helpPoint.y;
#endif #endif
#if ENABLE_PHYSICS_BOX2D_DETECT #if ENABLE_PHYSICS_BOX2D_DETECT

View File

@ -105,7 +105,7 @@ public:
virtual void setShape(cpShape *shape) { _shape = shape; } virtual void setShape(cpShape *shape) { _shape = shape; }
virtual cpShape *getShape() const { return _shape; } virtual cpShape *getShape() const { return _shape; }
#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
virtual cocos2d::Array *getCalculatedVertexList() const { return _calculatedVertexList; } virtual const std::vector<cocos2d::Point> &getCalculatedVertexList() const { return _calculatedVertexList; }
#endif #endif
private: private:
@ -117,10 +117,12 @@ private:
cpShape *_shape; cpShape *_shape;
ColliderFilter *_filter; ColliderFilter *_filter;
#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
cocos2d::Array *_calculatedVertexList; std::vector<cocos2d::Point> _calculatedVertexList;
#endif #endif
ContourData *_contourData; ContourData *_contourData;
friend class ColliderDetector;
}; };
/* /*
@ -148,7 +150,7 @@ public:
virtual bool init(Bone *bone); virtual bool init(Bone *bone);
void addContourData(ContourData *contourData); void addContourData(ContourData *contourData);
void addContourDataList(cocos2d::Array *contourDataList); void addContourDataList(cocos2d::Vector<ContourData*> &contourDataList);
void removeContourData(ContourData *contourData); void removeContourData(ContourData *contourData);
void removeAll(); void removeAll();

View File

@ -886,24 +886,24 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
frameXML = frameXML->NextSiblingElement(FRAME); frameXML = frameXML->NextSiblingElement(FRAME);
} }
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity) //! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
FrameData **frames = (FrameData **)movBoneData->frameList.data->arr; cocos2d::Vector<FrameData*> &frames = movBoneData->frameList;
for (int j = movBoneData->frameList.count() - 1; j >= 0; j--) for (int j = movBoneData->frameList.size() - 1; j >= 0; j--)
{ {
if (j > 0) if (j > 0)
{ {
float difSkewX = frames[j]->skewX - frames[j - 1]->skewX; float difSkewX = frames.at(j)->skewX - frames.at(j-1)->skewX;
float difSkewY = frames[j]->skewY - frames[j - 1]->skewY; float difSkewY = frames.at(j)->skewY - frames.at(j-1)->skewY;
if (difSkewX < -M_PI || difSkewX > M_PI) 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) 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 *frameData = new FrameData();
frameData->copy((FrameData *)movBoneData->frameList.getLastObject()); frameData->copy((FrameData *)movBoneData->frameList.back());
frameData->frameID = movBoneData->duration; frameData->frameID = movBoneData->duration;
movBoneData->addFrameData(frameData); movBoneData->addFrameData(frameData);
frameData->release(); frameData->release();
@ -1168,14 +1168,13 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D
while (vertexDataXML) while (vertexDataXML)
{ {
ContourVertex2 *vertex = new ContourVertex2(0, 0); Point vertex;
vertex->release();
vertexDataXML->QueryFloatAttribute(A_X, &vertex->x); vertexDataXML->QueryFloatAttribute(A_X, &vertex.x);
vertexDataXML->QueryFloatAttribute(A_Y, &vertex->y); vertexDataXML->QueryFloatAttribute(A_Y, &vertex.y);
vertex->y = -vertex->y; vertex.y = -vertex.y;
contourData->vertexList.addObject(vertex); contourData->vertexList.push_back(vertex);
vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX); vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX);
} }
@ -1514,22 +1513,22 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat
if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
{ {
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity) //! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
FrameData **frames = (FrameData **)movementBoneData->frameList.data->arr; cocos2d::Vector<FrameData *> &frames = movementBoneData->frameList;
for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--) for (int i = frames.size() - 1; i >= 0; i--)
{ {
if (i > 0) if (i > 0)
{ {
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX; float difSkewX = frames.at(i)->skewX - frames.at(i-1)->skewX;
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY; float difSkewY = frames.at(i)->skewY - frames.at(i-1)->skewY;
if (difSkewX < -M_PI || difSkewX > M_PI) 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) 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 (dataInfo->cocoStudioVersion < VERSION_COMBINED)
{ {
if (movementBoneData->frameList.count() > 0) if (movementBoneData->frameList.size() > 0)
{ {
FrameData *frameData = new FrameData(); FrameData *frameData = new FrameData();
frameData->copy((FrameData *)movementBoneData->frameList.getLastObject()); frameData->copy((FrameData *)movementBoneData->frameList.back());
movementBoneData->addFrameData(frameData); movementBoneData->addFrameData(frameData);
frameData->release(); frameData->release();
@ -1614,7 +1613,7 @@ TextureData *DataReaderHelper::decodeTexture(JsonDictionary &json)
{ {
JsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i); JsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i);
ContourData *contourData = decodeContour(*dic); ContourData *contourData = decodeContour(*dic);
textureData->contourDataList.addObject(contourData); textureData->contourDataList.pushBack(contourData);
contourData->release(); contourData->release();
delete dic; delete dic;
@ -1633,13 +1632,12 @@ ContourData *DataReaderHelper::decodeContour(JsonDictionary &json)
{ {
JsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i); JsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i);
ContourVertex2 *vertex = new ContourVertex2(0, 0); Point vertex;
vertex->x = dic->getItemFloatValue(A_X, 0); vertex.x = dic->getItemFloatValue(A_X, 0);
vertex->y = dic->getItemFloatValue(A_Y, 0); vertex.y = dic->getItemFloatValue(A_Y, 0);
contourData->vertexList.addObject(vertex); contourData->vertexList.push_back(vertex);
vertex->release();
delete dic; delete dic;
} }

View File

@ -208,18 +208,17 @@ BoneData::~BoneData(void)
bool BoneData::init() bool BoneData::init()
{ {
displayDataList.init();
return true; return true;
} }
void BoneData::addDisplayData(DisplayData *displayData) void BoneData::addDisplayData(DisplayData *displayData)
{ {
displayDataList.addObject(displayData); displayDataList.pushBack(displayData);
} }
DisplayData *BoneData::getDisplayData(int index) DisplayData *BoneData::getDisplayData(int index)
{ {
return static_cast<DisplayData *>(displayDataList.getObjectAtIndex(index)); return static_cast<DisplayData *>(displayDataList.at(index));
} }
@ -239,12 +238,12 @@ bool ArmatureData::init()
void ArmatureData::addBoneData(BoneData *boneData) void ArmatureData::addBoneData(BoneData *boneData)
{ {
boneDataDic.setObject(boneData, boneData->name); boneDataDic.insert(boneData->name, boneData);
} }
BoneData *ArmatureData::getBoneData(const char *boneName) BoneData *ArmatureData::getBoneData(const char *boneName)
{ {
return static_cast<BoneData*>(boneDataDic.objectForKey(boneName)); return static_cast<BoneData*>(boneDataDic.at(boneName));
} }
FrameData::FrameData(void) FrameData::FrameData(void)
@ -309,17 +308,17 @@ MovementBoneData::~MovementBoneData(void)
bool MovementBoneData::init() bool MovementBoneData::init()
{ {
return frameList.init(); return true;
} }
void MovementBoneData::addFrameData(FrameData *frameData) void MovementBoneData::addFrameData(FrameData *frameData)
{ {
frameList.addObject(frameData); frameList.pushBack(frameData);
} }
FrameData *MovementBoneData::getFrameData(int index) FrameData *MovementBoneData::getFrameData(int index)
{ {
return static_cast<FrameData*>(frameList.getObjectAtIndex(index)); return static_cast<FrameData*>(frameList.at(index));
} }
@ -341,12 +340,12 @@ MovementData::~MovementData(void)
void MovementData::addMovementBoneData(MovementBoneData *movBoneData) void MovementData::addMovementBoneData(MovementBoneData *movBoneData)
{ {
movBoneDataDic.setObject(movBoneData, movBoneData->name); movBoneDataDic.insert(movBoneData->name, movBoneData);
} }
MovementBoneData *MovementData::getMovementBoneData(const char *boneName) MovementBoneData *MovementData::getMovementBoneData(const char *boneName)
{ {
return static_cast<MovementBoneData *>(movBoneDataDic.objectForKey(boneName)); return static_cast<MovementBoneData *>(movBoneDataDic.at(boneName));
} }
@ -361,18 +360,18 @@ AnimationData::~AnimationData(void)
void AnimationData::addMovement(MovementData *movData) void AnimationData::addMovement(MovementData *movData)
{ {
movementDataDic.setObject(movData, movData->name); movementDataDic.insert(movData->name, movData);
movementNames.push_back(movData->name); movementNames.push_back(movData->name);
} }
MovementData *AnimationData::getMovement(const char *movementName) MovementData *AnimationData::getMovement(const char *movementName)
{ {
return static_cast<MovementData *>(movementDataDic.objectForKey(movementName)); return static_cast<MovementData *>(movementDataDic.at(movementName));
} }
int AnimationData::getMovementCount() int AnimationData::getMovementCount()
{ {
return movementDataDic.count(); return movementDataDic.size();
} }
@ -387,15 +386,12 @@ ContourData::~ContourData()
bool ContourData::init() 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); vertexList.push_back(vertex);
vertex2->autorelease();
vertexList.addObject(vertex2);
} }
TextureData::TextureData() TextureData::TextureData()
@ -413,17 +409,17 @@ TextureData::~TextureData()
bool TextureData::init() bool TextureData::init()
{ {
return contourDataList.init(); return true;
} }
void TextureData::addContourData(ContourData *contourData) void TextureData::addContourData(ContourData *contourData)
{ {
contourDataList.addObject(contourData); contourDataList.pushBack(contourData);
} }
ContourData *TextureData::getContourData(int index) ContourData *TextureData::getContourData(int index)
{ {
return static_cast<ContourData *>(contourDataList.getObjectAtIndex(index)); return static_cast<ContourData *>(contourDataList.at(index));
} }

View File

@ -250,7 +250,7 @@ public:
public: public:
std::string name; //! the bone's name std::string name; //! the bone's name
std::string parentName; //! the bone parent's name std::string parentName; //! the bone parent's name
cocos2d::Array displayDataList; //! save DisplayData informations for the Bone cocos2d::Vector<DisplayData*> displayDataList; //! save DisplayData informations for the Bone
cocos2d::AffineTransform boneDataTransform; cocos2d::AffineTransform boneDataTransform;
}; };
@ -282,7 +282,7 @@ public:
BoneData *getBoneData(const char *boneName); BoneData *getBoneData(const char *boneName);
public: public:
std::string name; std::string name;
cocos2d::Dictionary boneDataDic; cocos2d::Map<std::string, BoneData*> boneDataDic;
float dataVersion; float dataVersion;
}; };
@ -380,7 +380,7 @@ public:
float duration; //! this Bone in this movement will last m_iDuration frames float duration; //! this Bone in this movement will last m_iDuration frames
std::string name; //! bone name std::string name; //! bone name
cocos2d::Array frameList; cocos2d::Vector<FrameData*> frameList;
}; };
/** /**
@ -438,7 +438,7 @@ public:
* @key const char * * @key const char *
* @value MovementBoneData * * @value MovementBoneData *
*/ */
cocos2d::Dictionary movBoneDataDic; cocos2d::Map<std::string, MovementBoneData*> movBoneDataDic;
}; };
@ -469,22 +469,11 @@ public:
int getMovementCount(); int getMovementCount();
public: public:
std::string name; std::string name;
cocos2d::Dictionary movementDataDic; cocos2d::Map<std::string, MovementData*> movementDataDic;
std::vector<std::string> movementNames; std::vector<std::string> 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 * ContourData include a contour vertex information
@ -507,9 +496,9 @@ public:
~ContourData(void); ~ContourData(void);
virtual bool init(); virtual bool init();
virtual void addVertex(cocos2d::Point *vertex); virtual void addVertex(cocos2d::Point &vertex);
public: public:
cocos2d::Array vertexList; //! Save contour vertex info, vertex saved in a Point std::vector<cocos2d::Point> vertexList; //! Save contour vertex info, vertex saved in a Point
}; };
@ -549,7 +538,7 @@ public:
std::string name; //! The texture's name std::string name; //! The texture's name
cocos2d::Array contourDataList; cocos2d::Vector<ContourData*> contourDataList;
}; };

View File

@ -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 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 //! create ContourSprite
ColliderDetector *colliderDetector = ColliderDetector::create(bone); ColliderDetector *colliderDetector = ColliderDetector::create(bone);
colliderDetector->addContourDataList(&textureData->contourDataList); colliderDetector->addContourDataList(textureData->contourDataList);
decoDisplay->setColliderDetector(colliderDetector); decoDisplay->setColliderDetector(colliderDetector);
} }

View File

@ -141,7 +141,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
} }
_frameTweenEasing = Linear; _frameTweenEasing = Linear;
} }
else if (_movementBoneData->frameList.count() > 1) else if (_movementBoneData->frameList.size() > 1)
{ {
_durationTween = durationTween * _movementBoneData->scale; _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. * Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew.
* _toIndex is next index will play * _toIndex is next index will play
*/ */
int length = _movementBoneData->frameList.count(); int length = _movementBoneData->frameList.size();
FrameData **frames = (FrameData **)_movementBoneData->frameList.data->arr; cocos2d::Vector<FrameData *> &frames = _movementBoneData->frameList;
FrameData *from = nullptr; FrameData *from = nullptr;
FrameData *to = 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); setBetween(from, to);
return _currentPercent; 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 is true and playedTime >= frames[length - 1]->frameID, then do not need to go on.
if (_passLastFrame) if (_passLastFrame)
{ {
from = to = frames[length - 1]; from = to = frames.at(length - 1);
setBetween(from, to); setBetween(from, to);
return _currentPercent; return _currentPercent;
} }
@ -437,7 +437,7 @@ float Tween::updateFrameData(float currentPercent)
do do
{ {
_fromIndex = _toIndex; _fromIndex = _toIndex;
from = frames[_fromIndex]; from = frames.at(_fromIndex);
_totalDuration = from->frameID; _totalDuration = from->frameID;
_toIndex = _fromIndex + 1; _toIndex = _fromIndex + 1;
@ -446,7 +446,7 @@ float Tween::updateFrameData(float currentPercent)
_toIndex = 0; _toIndex = 0;
} }
to = frames[_toIndex]; to = frames.at(_toIndex);
//! Guaranteed to trigger frame event //! Guaranteed to trigger frame event
if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent()) if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent())

View File

@ -1040,24 +1040,24 @@ void TestColliderDetector::update(float delta)
for (auto object : *bodyList) for (auto object : *bodyList)
{ {
ColliderBody *body = static_cast<ColliderBody*>(object); ColliderBody *body = static_cast<ColliderBody*>(object);
Array *vertexList = body->getCalculatedVertexList(); const std::vector<Point> &vertexList = body->getCalculatedVertexList();
float minx, miny, maxx, maxy = 0; float minx, miny, maxx, maxy = 0;
int length = vertexList->count(); int length = vertexList.size();
for (int i = 0; i<length; i++) for (int i = 0; i<length; i++)
{ {
ContourVertex2 *vertex = static_cast<ContourVertex2*>(vertexList->getObjectAtIndex(i)); Point vertex = vertexList.at(i);
if (i == 0) if (i == 0)
{ {
minx = maxx = vertex->x; minx = maxx = vertex.x;
miny = maxy = vertex->y; miny = maxy = vertex.y;
} }
else else
{ {
minx = vertex->x < minx ? vertex->x : minx; minx = vertex.x < minx ? vertex.x : minx;
miny = vertex->y < miny ? vertex->y : miny; miny = vertex.y < miny ? vertex.y : miny;
maxx = vertex->x > maxx ? vertex->x : maxx; maxx = vertex.x > maxx ? vertex.x : maxx;
maxy = vertex->y > maxy ? vertex->y : maxy; maxy = vertex.y > maxy ? vertex.y : maxy;
} }
} }
Rect temp = Rect(minx, miny, maxx - minx, maxy - miny); Rect temp = Rect(minx, miny, maxx - minx, maxy - miny);

View File

@ -117,7 +117,7 @@ public:
virtual void addArmature(int number); virtual void addArmature(int number);
virtual void addArmatureToParent(cocostudio::Armature *armature); virtual void addArmatureToParent(cocostudio::Armature *armature);
virtual void removeArmatureFromParent(int tag); virtual void removeArmatureFromParent(int tag);
virtual void refreshTitile(); virtual void refreshTitle();
int armatureCount; int armatureCount;