佚名通过本文主要向大家介绍了vec2,vec2ind,matlab vec2ind,vec2mat,cocos2d vec2等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: cocos30 版本使用vec2的问题
描述:
描述:
最近在学习 “一个都不能死”的实战,在视频里面老师使用的是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);
}