mirror of https://github.com/axmolengine/axmol.git
change Array to Vector
This commit is contained in:
parent
0e8c3409e5
commit
917bd8c3d9
|
@ -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<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];
|
||||
for (int i = 0; i<length; i++)
|
||||
{
|
||||
ContourVertex2 *vertex = static_cast<ContourVertex2*>(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 );
|
||||
|
||||
|
|
|
@ -218,10 +218,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
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();
|
||||
if(movementBoneData && movementBoneData->frameList.count() > 0)
|
||||
if(movementBoneData && movementBoneData->frameList.size() > 0)
|
||||
{
|
||||
_tweenList->addObject(tween);
|
||||
movementBoneData->duration = _movementData->duration;
|
||||
|
|
|
@ -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<Point> &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<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
|
||||
|
||||
int num = contourData->vertexList.count();
|
||||
ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr;
|
||||
int num = contourData->vertexList.size();
|
||||
std::vector<cocos2d::Point> &vs = contourData->vertexList;
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
ContourVertex2 **cvs = (ContourVertex2 **)colliderBody->getCalculatedVertexList()->data->arr;
|
||||
std::vector<cocos2d::Point> &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
|
||||
|
|
|
@ -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<cocos2d::Point> &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<cocos2d::Point> _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<ContourData*> &contourDataList);
|
||||
|
||||
void removeContourData(ContourData *contourData);
|
||||
void removeAll();
|
||||
|
|
|
@ -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<FrameData*> &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<FrameData *> &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;
|
||||
}
|
||||
|
|
|
@ -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<DisplayData *>(displayDataList.getObjectAtIndex(index));
|
||||
return static_cast<DisplayData *>(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<BoneData*>(boneDataDic.objectForKey(boneName));
|
||||
return static_cast<BoneData*>(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<FrameData*>(frameList.getObjectAtIndex(index));
|
||||
return static_cast<FrameData*>(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<MovementBoneData *>(movBoneDataDic.objectForKey(boneName));
|
||||
return static_cast<MovementBoneData *>(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<MovementData *>(movementDataDic.objectForKey(movementName));
|
||||
return static_cast<MovementData *>(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<ContourData *>(contourDataList.getObjectAtIndex(index));
|
||||
return static_cast<ContourData *>(contourDataList.at(index));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<DisplayData*> 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<std::string, BoneData*> 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<FrameData*> frameList;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -438,7 +438,7 @@ public:
|
|||
* @key const char *
|
||||
* @value MovementBoneData *
|
||||
*/
|
||||
cocos2d::Dictionary movBoneDataDic;
|
||||
cocos2d::Map<std::string, MovementBoneData*> movBoneDataDic;
|
||||
};
|
||||
|
||||
|
||||
|
@ -469,22 +469,11 @@ public:
|
|||
int getMovementCount();
|
||||
public:
|
||||
std::string name;
|
||||
cocos2d::Dictionary movementDataDic;
|
||||
cocos2d::Map<std::string, MovementData*> movementDataDic;
|
||||
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
|
||||
|
@ -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<cocos2d::Point> 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<ContourData*> contourDataList;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<FrameData *> &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())
|
||||
|
|
|
@ -1040,24 +1040,24 @@ void TestColliderDetector::update(float delta)
|
|||
for (auto object : *bodyList)
|
||||
{
|
||||
ColliderBody *body = static_cast<ColliderBody*>(object);
|
||||
Array *vertexList = body->getCalculatedVertexList();
|
||||
const std::vector<Point> &vertexList = body->getCalculatedVertexList();
|
||||
|
||||
float minx, miny, maxx, maxy = 0;
|
||||
int length = vertexList->count();
|
||||
int length = vertexList.size();
|
||||
for (int i = 0; i<length; i++)
|
||||
{
|
||||
ContourVertex2 *vertex = static_cast<ContourVertex2*>(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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue