转载请说明出处:http://www.jb51.cc/article/p-skioadww-hx.html
http://www.jb51.cc/article/p-skioadww-hx.html
- std::stringfullPath=CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("images.json");
- unsignedlongsize;
- unsignedchar*file=CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(),"rt+",&size);
- std::stringstr="";
- for(inti=0;i<size;i++)
- {
- str+=file[i];
- }
- std::stringerror;
- b2dJsonjson;
- world=json.readFromString(str,error);
- b2dJsonImage*image1_=json.getImageByName("image1");
- CCSprite*image1=CCSprite::create("images/mcclory.png");
- image1->setScale((image1_->scale*PTM_RATIO)/image1->getTexture()->getPixelsHigh());
- image1Body->SetUserData(image1);
- this->addChild(image1,0);
注意在编辑的时候 图片的中心一定要和刚体的位置重合