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

C++ 如何在数组Cocos2d-x C+中存储点+;,c++,arrays,cocos2d-x,C++,Arrays,Cocos2d X,我正在使用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

我正在使用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);

}
myClass.h
矢量点阵列//使用cocos类向量,我对如何声明这个Points容器感到非常困惑。
myClass.cpp
//实现中的某些触发器将填充数组
整数计数;
int i;
浮动coinPosX;
浮动货币;
点1=向量2(0.8f,0.2f);
_pointArray.pushBack(点1);
点2=向量2(15.0华氏度,10.0华氏度);
_pointArray.pushBack(点2);
count=(int)u pointArray.size();
对于(i=0;i设置位置(Vec2(_pointArray.at(i).x,_pointArray.at(i).y));
这是一枚硬币;
}
问题在于后推方法的错误:

错误:没有重载函数“”cocos2d::Vector::pushback[带T=CoCoCos2D::Sprite*]的实例 匹配参数列表

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


这个参数不正确,所以我迷路了,这有什么错,在数组中存储点的正确方法是什么,我可以迭代并获取它的数据。谢谢你的指导。问候。

你不能这样储存它。向量是cocos2d-x,它需要cocos2d-x对象,它扩展了Ref类。相反,您可以使用std中的矢量(小写),如下所示:

std::vector<Point> _pointArray;
_pointArray.push_back(point1);
std::vector\u点数组;
_pointArray.push_back(点1);

您不能这样存储它。向量是cocos2d-x,它需要cocos2d-x对象,它扩展了Ref类。相反,您可以使用std中的矢量(小写),如下所示:

std::vector<Point> _pointArray;
_pointArray.push_back(point1);
std::vector\u点数组;
_pointArray.push_back(点1);

您对发布的代码有任何问题吗?它包含错误吗?编译时还是运行时?您需要告诉我们您的问题是什么。您对发布的代码有任何问题吗?它包含错误吗?编译时还是运行时?你需要告诉我们你的问题是什么,这是正确的方法。非常感谢你。你好,这是正确的方法。非常感谢你。问候语。