加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d-x用rube box2d editor当关卡编辑器写游戏

发布时间:2020-12-14 19:45:21 所属栏目:百科 来源:网络整理
导读:转载请说明出处 :http://www.jb51.cc/article/p-skioadww-hx.html http://www.jb51.cc/article/p-skioadww-hx.html [cpp] view plain copy std::stringfullPath=CCFileUtils::sharedFileUtils()-fullPathFromRelativePath( "images.json" ); unsigned long

转载请说明出处:http://www.52php.cn/article/p-skioadww-hx.html

http://www.52php.cn/article/p-skioadww-hx.html

[cpp] view plain copy
  1. std::stringfullPath=CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("images.json");
  2. unsignedlongsize;
  3. unsignedchar*file=CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(),"rt+",&size);
  4. std::stringstr="";
  5. for(inti=0;i<size;i++)
  6. {
  7. str+=file[i];
  8. }
  9. std::stringerror;
  10. b2dJsonjson;
  11. world=json.readFromString(str,error);
  12. b2dJsonImage*image1_=json.getImageByName("image1");
  13. CCSprite*image1=CCSprite::create("images/mcclory.png");
  14. image1->setScale((image1_->scale*PTM_RATIO)/image1->getTexture()->getPixelsHigh());
  15. image1Body->SetUserData(image1);
  16. this->addChild(image1,0);

注意在编辑的时候 图片的中心一定要和刚体的位置重合


软件地址:https://www.iforce2d.net/rube/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读