[Tutorials]use rube whit cocos2d or cocos2d-x

General discussion about the R.U.B.E editor
Post Reply
qq200600
Posts: 29
Joined: Fri Dec 28, 2012 9:27 am

[Tutorials]use rube whit cocos2d or cocos2d-x

Post by qq200600 »

Code: Select all

std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("images.json");
	unsigned long size;
	unsigned char *file = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "rt+", &size);
	std::string str = "";
	for (int i = 0; i < size; i++)
	{
		str += file[i];
	}
	std::string error;
	b2dJson json;
	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);

if you do this, you can run the images.json nicely. note: the image1's center must as same as the image1Body's position.


If you want to look the picture what i deal with, please link : http://blog.csdn.net/qq634416025/articl ... ls/8648758
Post Reply