如何在数组 Cocos2d-x C++ 中存储点

How to store Points in an Array Cocos2d-x C++

我正在使用 Cocos2d-x,我想知道如何在数组中存储点。

myClass.h
Vector<Point*> _pointArray; //Using the cocos class Vector Im getting really confused about how to declare this Points container. 

myClass.cpp

//Some trigger in the implementation will populate the array
int count;
int i;
float coinPosX;
float coinPosY;

Point point1 = Vec2(0.8f, 0.2f);
_pointArray.pushBack(point1);

Point point2 = Vec2(15.0f, 10.0f);
_pointArray.pushBack(point2);

count = (int)_pointArray.size();

for (i = 0; i < count; i++){
    auto coin = Sprite::create("coin.png");
    coin->setPosition(Vec2( _pointArray.at(i).x,  _pointArray.at(i).y));
    this->addChild(coin);

}

问题是 pushBack 方法的错误:

错误:没有重载函数实例''cocos2d::Vector::pushback[with T=cocos2d::Sprite*] 匹配参数列表

参数类型是(cocos2d::Point) 对象类型是 cocos2d::Vector;

论点不对,所以我迷路了,这有什么问题,将点存储在数组中的正确方法是什么,我可以迭代并获取其数据。感谢您的指导。你好。

不能这样存放。 Vector 是 cocos2d-x,它需要 cocos2d-x 个对象,这些对象扩展了 Ref class。相反,您可以像这样使用来自 std 的向量(小写):

std::vector<Point> _pointArray;
_pointArray.push_back(point1);