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

来源:互联网 发布:facebook无法连接网络 编辑:程序博客网 时间:2024/05/21 19:35

转载请说明出处:http://blog.csdn.net/qq634416025/article/details/8648758

转载请说明出处:http://blog.csdn.net/qq634416025/article/details/8648758

[cpp] view plaincopy
  1. std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("images.json");  
  2.    unsigned long size;  
  3.    unsigned char *file = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "rt+", &size);  
  4.    std::string str = "";  
  5.    for (int i = 0; i < size; i++)  
  6.    {  
  7.       str += file[i];  
  8.    }  
  9.    std::string error;  
  10.    b2dJson json;  
  11.    world = json.readFromString(str, error);  
  12.   
  13. b2dJsonImage *image1_ = json.getImageByName("image1");  
  14.   
  15. CCSprite *image1 = CCSprite::create("images/mcclory.png");  
  16. image1->setScale((image1_->scale * PTM_RATIO)/ image1->getTexture()->getPixelsHigh());  
  17.   
  18. image1Body->SetUserData(image1);  
  19.   
  20. this->addChild(image1, 0);  

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


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

0 0
原创粉丝点击