TMX调试object数据点调试代码

unsigned int length = pointsArray.size(); // XXX
cocos2d::Vec2 *points = new cocos2d::Vec2[length];//XXX
int cnt = 0;// XXX
for (auto& p : pointsArray) {
    ValueMap &a = p.asValueMap();
    Vec2 *th = &points[cnt];//xxx
    th->x = a["x"].asFloat();//xxx
    th->y = a["y"].asFloat();//xxx
    cnt++;//xxx
}
DrawNode *node = DrawNode::create();
node->drawPoly(points, length, true, Color4F(1, 0, 0, 1));
addChild(node);
node->setPosition(xPos);
float rotation = 0;
if (dict.find("rotation") != dict.end()) {
    rotation = dict["rotation"].asFloat();
}
node->setRotation(rotation);
// set data for sort
Vec2 *data = new Vec2(xPos);
node->setUserData((void *)data);

标签: Cocos2d-x

添加新评论