mirror of https://github.com/axmolengine/axmol.git
Merge pull request #13801 from chengstory/OptimizateDoLayout
Move "ui::Helper::DoLayout" to "CreateNode"。
This commit is contained in:
commit
dbe3e062bc
|
@ -295,6 +295,30 @@ Node* CSLoader::createNode(const std::string &filename, const ccNodeLoadCallback
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Node* CSLoader::createNodeWithVisibleSize(const std::string& filename)
|
||||
{
|
||||
auto node = createNode(filename);
|
||||
if (node != nullptr)
|
||||
{
|
||||
Size frameSize = Director::getInstance()->getVisibleSize();
|
||||
node->setContentSize(frameSize);
|
||||
ui::Helper::doLayout(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* CSLoader::createNodeWithVisibleSize(const std::string &filename, const ccNodeLoadCallback &callback)
|
||||
{
|
||||
auto node = createNode(filename, callback);
|
||||
if (node != nullptr)
|
||||
{
|
||||
Size frameSize = Director::getInstance()->getVisibleSize();
|
||||
node->setContentSize(frameSize);
|
||||
ui::Helper::doLayout(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
std::string CSLoader::getExtentionName(const std::string& name)
|
||||
{
|
||||
std::string result = "";
|
||||
|
|
|
@ -81,6 +81,8 @@ public:
|
|||
static cocos2d::Node* createNode(const std::string& filename, const ccNodeLoadCallback& callback);
|
||||
static cocos2d::Node* createNode(const Data data);
|
||||
static cocos2d::Node* createNode(const Data data, const ccNodeLoadCallback &callback);
|
||||
static cocos2d::Node* createNodeWithVisibleSize(const std::string& filename);
|
||||
static cocos2d::Node* createNodeWithVisibleSize(const std::string& filename, const ccNodeLoadCallback& callback);
|
||||
|
||||
static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename);
|
||||
static cocostudio::timeline::ActionTimeline* createTimeline(const Data data, const std::string& filename);
|
||||
|
|
|
@ -193,6 +193,28 @@ ccs.load = function(file, path){
|
|||
return object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Analysis of studio JSON file and layout ui widgets by visible size.
|
||||
* The incoming file name, parse out the corresponding object
|
||||
* Temporary support file list:
|
||||
* ui 1.*
|
||||
* node 1.* - 2.*
|
||||
* action 1.* - 2.*
|
||||
* scene 0.* - 1.*
|
||||
* @param {String} file
|
||||
* @param {String} [path=] Resource path
|
||||
* @returns {{node: cc.Node, action: cc.Action}}
|
||||
*/
|
||||
ccs.loadWithVisibleSize = function(file, path){
|
||||
var object = ccs.load(file, path);
|
||||
var size = cc.director.getVisibleSize();
|
||||
if(object.node && size){
|
||||
object.node.setContentSize(size.width, size.height);
|
||||
ccui.helper.doLayout(object.node);
|
||||
}
|
||||
return object;
|
||||
};
|
||||
|
||||
//Forward compatible interface
|
||||
|
||||
ccs.actionTimelineCache = {
|
||||
|
|
Loading…
Reference in New Issue