cocos3.0 版本使用vec2的问题

Mygamesd 2016-02-06 05:26:41
最近在学习 “一个都不能死”的实战,在视频里面老师使用的是3.1版本,我在使用vec2的时候发现他显示未定义,尝试使用头文件
#include <Vector2.h>则说找不到源文件,请求帮助。

#include "FlashTool.h"
#include <json/document.h>
#include <Vector2.h>


Animate * FlashTool::readJsonSpriteSheet(std::string jsonFile,float delayPerUnit){

rapidjson::Document doc;
std::string fileContent = FileUtils::getInstance()->getStringFromFile(jsonFile);
fileContent.erase(0,fileContent.find_first_of('{'));

doc.Parse<0>(fileContent.c_str());

std::string imgFileName = doc["meta"]["image"].GetString();

auto &frames = doc["frames"];
auto sfc = SpriteFrameCache::getInstance();

Vector<AnimationFrame*> animFrames;
for (auto m=frames.MemberonBegin(); m!=frames.MemberonEnd(); m++) {
auto frameName = m->name.GetString();
auto & frameProperties = m->value["frame"];
auto & spriteSourceSize = m->value["spriteSourceSize"];

auto sf = sfc->getSpriteFrameByName(frameName);
if (!sf) {
sf = SpriteFrame::create(imgFileName, Rect(frameProperties["x"].GetInt(), frameProperties["y"].GetInt(), frameProperties["w"].GetInt(), frameProperties["h"].GetInt()), m->value["rotated"].GetBool(), Vec2(spriteSourceSize["x"].GetInt(), spriteSourceSize["y"].GetInt()), Size(spriteSourceSize["w"].GetInt(), spriteSourceSize["h"].GetInt()));
sfc->addSpriteFrame(sf, frameName);
}
animFrames.pushBack(AnimationFrame::create(sf, delayPerUnit, ValueMapNull));
}

Animation * animation = Animation::create(animFrames,delayPerUnit);
return Animate::create(animation);
}

...全文
449 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
赫夫曼树 2017-02-05
  • 打赏
  • 举报
回复
貌似3.0版本中Vect可以代替vec2
LR1741670057 2016-05-05
  • 打赏
  • 举报
回复
额。。。我的不是这个问题。也是同一段代码,但我看的视频上没说Vector2.h。而是MemberonBegin()和MemberonEnd(),报错啦。是这样的。如图。楼主你的问题应该解决了吧。看看我这个是怎么回事呗。网上搜了好多,都是通过一个代码。我的邮箱1741670057@qq.com。还有我用的是3.10版本的
a1731969799 2016-03-23
  • 打赏
  • 举报
回复
我也是这个问题。。。。。。。。。。。。。。。

721

社区成员

发帖
与我相关
我的任务
社区描述
Cocos2d-x相关内容讨论专区
社区管理员
  • Cocos2d-x
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧