From e9e9741a744c2728ca3b7cf20a83f4ab5357539c Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 9 Sep 2014 22:30:52 +0900 Subject: [PATCH] SceneReader sets contentSize by canvasSize. We could not get the canvas size of the scene which created on CocosStudio. Thanks to this commit, we can get scene's canvas size by Node::getContentSize() ```cpp auto scene = cocos2d::cocostudio::SceneReader::getInstance()->createNodeWithSceneFile("Scene.json"); int width = scene->getContentSize().width; int height = scene->getContentSize().height; cocos2d::log("canvasSize = %d, %d", width, height); ``` --- cocos/editor-support/cocostudio/CCSSceneReader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index c61ba81f2a..c0de120d4f 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -341,6 +341,14 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par createObject(subDict, gb, attachComponent); } + const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize"); + if (DICTOOL->checkObjectExist_json(canvasSizeDict)) + { + int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width"); + int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height"); + gb->setContentSize(Size(width, height)); + } + return gb; }