mirror of https://github.com/axmolengine/axmol.git
Merge pull request #12182 from VisualSJ/v3-jsb
[ci skip] Synchronization studio parser
This commit is contained in:
commit
12de53726d
|
@ -36,7 +36,7 @@ ccs._load = (function(){
|
||||||
var json = cc.loader.getRes(file);
|
var json = cc.loader.getRes(file);
|
||||||
|
|
||||||
if(!json)
|
if(!json)
|
||||||
return cc.log("%s is not exists", file);
|
return cc.log("%s does not exist", file);
|
||||||
var ext = extname(file).toLocaleLowerCase();
|
var ext = extname(file).toLocaleLowerCase();
|
||||||
if(ext !== "json" && ext !== "exportjson")
|
if(ext !== "json" && ext !== "exportjson")
|
||||||
return cc.log("%s load error, must be json file", file);
|
return cc.log("%s load error, must be json file", file);
|
||||||
|
|
|
@ -51,11 +51,11 @@
|
||||||
if(parser)
|
if(parser)
|
||||||
frame = parser.call(self, timeline, resourcePath);
|
frame = parser.call(self, timeline, resourcePath);
|
||||||
else
|
else
|
||||||
cc.log("parser is not exists : %s", timeline["frameType"]);
|
cc.log("parser does not exist : %s", timeline["frameType"]);
|
||||||
if(frame)
|
if(frame)
|
||||||
action.addTimeline(frame);
|
action.addTimeline(frame);
|
||||||
|
|
||||||
if(timeline["frameType"] == "ColorFrame"){
|
if(timeline["frameType"] === "ColorFrame"){
|
||||||
action.addTimeline(
|
action.addTimeline(
|
||||||
self.parsers["AlphaFrame"].call(self, timeline, resourcePath)
|
self.parsers["AlphaFrame"].call(self, timeline, resourcePath)
|
||||||
);
|
);
|
||||||
|
@ -235,4 +235,4 @@
|
||||||
|
|
||||||
load.registerParser("action", "*", parser);
|
load.registerParser("action", "*", parser);
|
||||||
|
|
||||||
})(ccs._load, ccs._parser);
|
})(ccs._load, ccs._parser);
|
||||||
|
|
|
@ -149,8 +149,16 @@
|
||||||
frame.setAnchorPoint(cc.p(anchorx, anchory));
|
frame.setAnchorPoint(cc.p(anchorx, anchory));
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
},
|
},{
|
||||||
{
|
name: "AnchorPoint",
|
||||||
|
handle: function(options){
|
||||||
|
var frame = new ccs.AnchorPointFrame();
|
||||||
|
var anchorx = options["X"];
|
||||||
|
var anchory = options["Y"];
|
||||||
|
frame.setAnchorPoint(cc.p(anchorx, anchory));
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
},{
|
||||||
name: "InnerAction",
|
name: "InnerAction",
|
||||||
handle: function(options){
|
handle: function(options){
|
||||||
var frame = new ccs.InnerActionFrame();
|
var frame = new ccs.InnerActionFrame();
|
||||||
|
@ -186,11 +194,20 @@
|
||||||
{
|
{
|
||||||
name: "FileData",
|
name: "FileData",
|
||||||
handle: function(options, resourcePath){
|
handle: function(options, resourcePath){
|
||||||
var frame = new ccs.TextureFrame();
|
var frame, texture, plist, path, spriteFrame;
|
||||||
var texture = options["TextureFile"];
|
frame = new ccs.TextureFrame();
|
||||||
|
texture = options["TextureFile"];
|
||||||
if(texture != null) {
|
if(texture != null) {
|
||||||
var path = texture["Path"];
|
plist = texture["Plist"];
|
||||||
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
|
path = texture["Path"];
|
||||||
|
spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
|
||||||
|
if(!spriteFrame && plist){
|
||||||
|
if(cc.loader.getRes(resourcePath + plist)){
|
||||||
|
cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
|
||||||
|
}else{
|
||||||
|
cc.log("%s need to be preloaded", resourcePath + plist);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(spriteFrame == null){
|
if(spriteFrame == null){
|
||||||
path = resourcePath + path;
|
path = resourcePath + path;
|
||||||
}
|
}
|
||||||
|
@ -249,11 +266,13 @@
|
||||||
var type = options["Type"];
|
var type = options["Type"];
|
||||||
frame.setTweenType(type);
|
frame.setTweenType(type);
|
||||||
var points = options["Points"];
|
var points = options["Points"];
|
||||||
|
var result = [];
|
||||||
if(points){
|
if(points){
|
||||||
points = points.map(function(p){
|
points.forEach(function(p){
|
||||||
return cc.p(p["X"], p["Y"]);
|
result.push(p["X"]);
|
||||||
|
result.push(p["Y"]);
|
||||||
});
|
});
|
||||||
frame.setEasingParams(points);
|
frame.setEasingParams(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
widgetFromJsonFile: function(file){
|
widgetFromJsonFile: function(file){
|
||||||
var json = cc.loader.getRes(file);
|
var json = cc.loader.getRes(cc.path.join(cc.loader.resPath, file));
|
||||||
if(json)
|
if(json)
|
||||||
this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0);
|
this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0);
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
getVersionInteger: function(version){
|
getVersionInteger: function(version){
|
||||||
if(!version || typeof version != "string") return 0;
|
if(!version || typeof version !== "string") return 0;
|
||||||
var arr = version.split(".");
|
var arr = version.split(".");
|
||||||
if (arr.length != 4)
|
if (arr.length !== 4)
|
||||||
return 0;
|
return 0;
|
||||||
var num = 0;
|
var num = 0;
|
||||||
arr.forEach(function(n, i){
|
arr.forEach(function(n, i){
|
||||||
|
@ -199,7 +199,7 @@
|
||||||
getNodeByTag: function(tag){
|
getNodeByTag: function(tag){
|
||||||
if (this._node == null)
|
if (this._node == null)
|
||||||
return null;
|
return null;
|
||||||
if (this._node.getTag() == tag)
|
if (this._node.getTag() === tag)
|
||||||
return this._node;
|
return this._node;
|
||||||
return this._nodeByTag(this._node, tag);
|
return this._nodeByTag(this._node, tag);
|
||||||
},
|
},
|
||||||
|
@ -211,7 +211,7 @@
|
||||||
var children = parent.getChildren();
|
var children = parent.getChildren();
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
if (child && child.getTag() == tag) {
|
if (child && child.getTag() === tag) {
|
||||||
retNode = child;
|
retNode = child;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -92,9 +92,9 @@
|
||||||
"CCSprite": function(node, component, resourcePath){
|
"CCSprite": function(node, component, resourcePath){
|
||||||
var child = new cc.Sprite();
|
var child = new cc.Sprite();
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0)
|
if(type === 0)
|
||||||
child.setTexture(path);
|
child.setTexture(path);
|
||||||
else if(type == 1){
|
else if(type === 1){
|
||||||
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
|
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
|
||||||
child.setSpriteFrame(spriteFrame);
|
child.setSpriteFrame(spriteFrame);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
"CCTMXTiledMap": function(node, component, resourcePath){
|
"CCTMXTiledMap": function(node, component, resourcePath){
|
||||||
var child = null;
|
var child = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0)
|
if(type === 0)
|
||||||
child = new cc.TMXTiledMap(path);
|
child = new cc.TMXTiledMap(path);
|
||||||
});
|
});
|
||||||
var render = new ccs.ComRender(child, "CCTMXTiledMap");
|
var render = new ccs.ComRender(child, "CCTMXTiledMap");
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
"CCParticleSystemQuad": function(node, component, resourcePath){
|
"CCParticleSystemQuad": function(node, component, resourcePath){
|
||||||
var child = null;
|
var child = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0)
|
if(type === 0)
|
||||||
child = new cc.ParticleSystem(path);
|
child = new cc.ParticleSystem(path);
|
||||||
else
|
else
|
||||||
cc.log("unknown resourcetype on CCParticleSystemQuad!");
|
cc.log("unknown resourcetype on CCParticleSystemQuad!");
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
"CCArmature": function(node, component, resourcePath){
|
"CCArmature": function(node, component, resourcePath){
|
||||||
var child = null;
|
var child = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0){
|
if(type === 0){
|
||||||
var jsonDict = cc.loader.getRes(path);
|
var jsonDict = cc.loader.getRes(path);
|
||||||
if (!jsonDict) cc.log("Please load the resource [%s] first!", path);
|
if (!jsonDict) cc.log("Please load the resource [%s] first!", path);
|
||||||
var armature_data = jsonDict["armature_data"];
|
var armature_data = jsonDict["armature_data"];
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
"CCComAudio": function(node, component, resourcePath){
|
"CCComAudio": function(node, component, resourcePath){
|
||||||
var audio = null;
|
var audio = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0){
|
if(type === 0){
|
||||||
audio = new ccs.ComAudio();
|
audio = new ccs.ComAudio();
|
||||||
audio.preloadEffect(path);
|
audio.preloadEffect(path);
|
||||||
var name = component["name"];
|
var name = component["name"];
|
||||||
|
@ -166,9 +166,9 @@
|
||||||
"CCComAttribute": function(node, component, resourcePath){
|
"CCComAttribute": function(node, component, resourcePath){
|
||||||
var attribute = null;
|
var attribute = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0){
|
if(type === 0){
|
||||||
attribute = new ccs.ComAttribute();
|
attribute = new ccs.ComAttribute();
|
||||||
if (path != "")
|
if (path !== "")
|
||||||
attribute.parse(path);
|
attribute.parse(path);
|
||||||
node.addComponent(attribute);
|
node.addComponent(attribute);
|
||||||
}else
|
}else
|
||||||
|
@ -179,7 +179,7 @@
|
||||||
"CCBackgroundAudio": function(node, component, resourcePath){
|
"CCBackgroundAudio": function(node, component, resourcePath){
|
||||||
var audio = null;
|
var audio = null;
|
||||||
loadTexture(component["fileData"], resourcePath, function(path, type){
|
loadTexture(component["fileData"], resourcePath, function(path, type){
|
||||||
if(type == 0){
|
if(type === 0){
|
||||||
audio = new ccs.ComAudio();
|
audio = new ccs.ComAudio();
|
||||||
audio.preloadBackgroundMusic(path);
|
audio.preloadBackgroundMusic(path);
|
||||||
audio.setFile(path);var bLoop = Boolean(component["loop"] || 0);
|
audio.setFile(path);var bLoop = Boolean(component["loop"] || 0);
|
||||||
|
|
|
@ -121,6 +121,8 @@
|
||||||
|
|
||||||
node.setCascadeColorEnabled(true);
|
node.setCascadeColorEnabled(true);
|
||||||
node.setCascadeOpacityEnabled(true);
|
node.setCascadeOpacityEnabled(true);
|
||||||
|
|
||||||
|
setLayoutComponent(node, json);
|
||||||
};
|
};
|
||||||
|
|
||||||
parser.parseChild = function(node, children, resourcePath){
|
parser.parseChild = function(node, children, resourcePath){
|
||||||
|
@ -327,6 +329,11 @@
|
||||||
if (color != null)
|
if (color != null)
|
||||||
widget.setColor(getColor(color));
|
widget.setColor(getColor(color));
|
||||||
|
|
||||||
|
setLayoutComponent(widget, json);
|
||||||
|
};
|
||||||
|
|
||||||
|
var setLayoutComponent = function(widget, json){
|
||||||
|
|
||||||
var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget);
|
var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget);
|
||||||
if(!layoutComponent)
|
if(!layoutComponent)
|
||||||
return;
|
return;
|
||||||
|
@ -562,8 +569,11 @@
|
||||||
|
|
||||||
widget.setUnifySizeEnabled(false);
|
widget.setUnifySizeEnabled(false);
|
||||||
|
|
||||||
|
var color = json["CColor"];
|
||||||
|
json["CColor"] = null;
|
||||||
|
widget.setTextColor(getColor(color));
|
||||||
this.widgetAttributes(widget, json, widget.isIgnoreContentAdaptWithSize());
|
this.widgetAttributes(widget, json, widget.isIgnoreContentAdaptWithSize());
|
||||||
|
json["CColor"] = color;
|
||||||
return widget;
|
return widget;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1131,13 +1141,10 @@
|
||||||
var volume = json["Volume"] || 0;
|
var volume = json["Volume"] || 0;
|
||||||
cc.audioEngine.setMusicVolume(volume);
|
cc.audioEngine.setMusicVolume(volume);
|
||||||
//var name = json["Name"];
|
//var name = json["Name"];
|
||||||
var resPath = "";
|
|
||||||
if(cc.loader.resPath)
|
|
||||||
resPath = (cc.loader.resPath + "/").replace(/\/\/$/, "/");
|
|
||||||
|
|
||||||
loadTexture(json["FileData"], resourcePath, function(path, type){
|
loadTexture(json["FileData"], resourcePath, function(path, type){
|
||||||
cc.loader.load(path, function(){
|
cc.loader.load(path, function(){
|
||||||
cc.audioEngine.playMusic(resPath + path, loop);
|
cc.audioEngine.playMusic(path, loop);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1235,6 +1242,7 @@
|
||||||
node.getAnimation().play(currentAnimationName, -1, isLoop);
|
node.getAnimation().play(currentAnimationName, -1, isLoop);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
node.setColor(getColor(json["CColor"]));
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
widget.pushBackCustomItem(child);
|
widget.pushBackCustomItem(child);
|
||||||
} else {
|
} else {
|
||||||
if(!(widget instanceof ccui.Layout)) {
|
if(!(widget instanceof ccui.Layout)) {
|
||||||
if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) {
|
if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) {
|
||||||
var position = child.getPositionPercent();
|
var position = child.getPositionPercent();
|
||||||
var anchor = widget.getAnchorPoint();
|
var anchor = widget.getAnchorPoint();
|
||||||
child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y));
|
child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y));
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
|
|
||||||
var getPath = function(res, type, path, cb){
|
var getPath = function(res, type, path, cb){
|
||||||
if(path){
|
if(path){
|
||||||
if(type == 0)
|
if(type === 0)
|
||||||
cb(res + path, type);
|
cb(res + path, type);
|
||||||
else
|
else
|
||||||
cb(path, type);
|
cb(path, type);
|
||||||
|
|
Loading…
Reference in New Issue