Skip to content

Commit 570e2a3

Browse files
committed
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-js into develop
2 parents 72ea23a + d0da3e0 commit 570e2a3

File tree

4 files changed

+84
-34
lines changed

4 files changed

+84
-34
lines changed

frameworks/js-bindings/bindings/script/studio/jsb_cocos2d_studio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ccs.MovementEventType = {
4141
ccs.InnerActionType = {
4242
LoopAction: 0,
4343
NoLoopAction: 1,
44-
SingleFrame: 2,
44+
SingleFrame: 2
4545
};
4646

4747
// Armature

frameworks/js-bindings/bindings/script/studio/jsb_studio_load.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ ccs.load = function(file){
180180

181181
object.node = ccs._load(file);
182182
object.action = ccs._load(file, "action");
183+
if(object.action && object.action.tag === -1 && object.node)
184+
object.action.tag = object.node.tag;
183185
return object;
184186
};
185187

frameworks/js-bindings/bindings/script/studio/parsers/action-2.x.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@
5959
cache[file] = action;
6060
cache[file].retain();
6161
return action.clone();
62+
},
63+
64+
deferred: function(json, resourcePath, action, file){
65+
if(cc.sys.isNative){
66+
var animationlist = json["Content"]["Content"]["AnimationList"];
67+
var length = animationlist ? animationlist.length : 0;
68+
for (var i = 0; i < length; i++){
69+
var animationdata = animationlist[i];
70+
var info = { name: null, startIndex: null, endIndex: null };
71+
info.name = animationdata["Name"];
72+
info.startIndex = animationdata["StartIndex"];
73+
info.endIndex = animationdata["EndIndex"];
74+
action.addAnimationInfo(info);
75+
}
76+
}
6277
}
6378

6479
});
@@ -201,6 +216,26 @@
201216
var frame = new ccs.ZOrderFrame();
202217
var zorder = options["Value"];
203218
frame.setZOrder(zorder);
219+
return frame;
220+
}
221+
},
222+
{
223+
name: "ActionValue",
224+
handle: function (options) {
225+
226+
var frame = new ccs.InnerActionFrame();
227+
var innerActionType = options["InnerActionType"];
228+
229+
var currentAnimationFrame = options["CurrentAniamtionName"];
230+
231+
var singleFrameIndex = options["SingleFrameIndex"];
232+
233+
frame.setInnerActionType(ccs.InnerActionType[innerActionType]);
234+
frame.setSingleFrameIndex(singleFrameIndex);
235+
236+
frame.setEnterWithName(true);
237+
frame.setAnimationName(currentAnimationFrame);
238+
204239
return frame;
205240
}
206241
}

frameworks/js-bindings/bindings/script/studio/parsers/timelineParser-2.x.js

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@
280280

281281
var scale = json["Scale"];
282282
if(scale != null){
283-
widget.setScaleX(scale["ScaleX"] || 1);
284-
widget.setScaleY(scale["ScaleY"] || 1);
283+
var scaleX = getParam(scale["ScaleX"], 1);
284+
var scaleY = getParam(scale["ScaleY"], 1);
285+
widget.setScaleX(scaleX);
286+
widget.setScaleY(scaleY);
285287
}
286288

287289
var anchorPoint = json["AnchorPoint"];
@@ -372,7 +374,7 @@
372374

373375
this.widgetAttributes(widget, json);
374376

375-
var clipEnabled = json["ClipAple"];
377+
var clipEnabled = json["ClipAble"];
376378
if(clipEnabled != null)
377379
widget.setClippingEnabled(clipEnabled);
378380

@@ -387,7 +389,7 @@
387389
if(backGroundScale9Enabled != null)
388390
widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled);
389391

390-
var opacity = json["Alpha"] || 255;
392+
var opacity = getParam(json["Alpha"], 255);
391393
widget.setOpacity(opacity);
392394

393395
loadTexture(json["FileData"], resourcePath, function(path, type){
@@ -640,8 +642,7 @@
640642
this.widgetAttributes(widget, json);
641643

642644
var clipEnabled = json["ClipAble"];
643-
if(clipEnabled)
644-
widget.setClippingEnabled(true);
645+
widget.setClippingEnabled(clipEnabled);
645646

646647
var colorType = getParam(json["ComboBoxIndex"], 0);
647648
widget.setBackGroundColorType(colorType);
@@ -681,7 +682,9 @@
681682

682683
var colorVector = json["ColorVector"];
683684
if(colorVector){
684-
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"] || 1, colorVector["ScaleY"] || 1));
685+
var colorVectorX = getParam(colorVector["ScaleX"], 1);
686+
var colorVectorY = getParam(colorVector["ScaleY"], 1);
687+
widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY));
685688
}
686689

687690
loadTexture(json["FileData"], resourcePath, function(path, type){
@@ -690,8 +693,8 @@
690693

691694
var innerNodeSize = json["InnerNodeSize"];
692695
var innerSize = cc.size(
693-
innerNodeSize["width"] || 0,
694-
innerNodeSize["height"] || 0
696+
innerNodeSize["Width"] || 0,
697+
innerNodeSize["Height"] || 0
695698
);
696699
widget.setInnerContainerSize(innerSize);
697700

@@ -734,10 +737,10 @@
734737
var scale9Width = json["Scale9Width"] || 0;
735738
var scale9Height = json["Scale9Height"] || 0;
736739
widget.setCapInsets(cc.rect(
737-
scale9OriginX ,
738-
scale9OriginY,
739-
scale9Width,
740-
scale9Height
740+
scale9OriginX ,
741+
scale9OriginY,
742+
scale9Width,
743+
scale9Height
741744
));
742745
} else
743746
setContentSize(widget, json["Size"]);
@@ -822,9 +825,8 @@
822825

823826
this.widgetAttributes(widget, json);
824827

825-
var clipEnabled = json["ClipAble"];
826-
if(clipEnabled)
827-
widget.setClippingEnabled(true);
828+
var clipEnabled = json["ClipAble"] || false;
829+
widget.setClippingEnabled(clipEnabled);
828830

829831
var backGroundScale9Enabled = json["Scale9Enable"];
830832
if(backGroundScale9Enabled){
@@ -835,10 +837,10 @@
835837
var scale9Width = json["Scale9Width"] || 0;
836838
var scale9Height = json["Scale9Height"] || 0;
837839
widget.setBackGroundImageCapInsets(cc.rect(
838-
scale9OriginX,
839-
scale9OriginY,
840-
scale9Width,
841-
scale9Height
840+
scale9OriginX,
841+
scale9OriginY,
842+
scale9Width,
843+
scale9Height
842844
));
843845
}
844846

@@ -859,7 +861,7 @@
859861

860862
var colorVector = json["ColorVector"];
861863
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
862-
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
864+
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"]));
863865
if(bgColorOpacity != null)
864866
widget.setBackGroundColorOpacity(bgColorOpacity);
865867

@@ -885,9 +887,8 @@
885887

886888
this.widgetAttributes(widget, json);
887889

888-
var clipEnabled = json["ClipAble"];
889-
if(clipEnabled)
890-
widget.setClippingEnabled(true);
890+
var clipEnabled = json["ClipAble"] || false;
891+
widget.setClippingEnabled(clipEnabled);
891892

892893
var colorType = getParam(json["ComboBoxIndex"], 0);
893894
widget.setBackGroundColorType(colorType);
@@ -902,10 +903,10 @@
902903
var scale9Width = json["Scale9Width"] || 0;
903904
var scale9Height = json["Scale9Height"] || 0;
904905
widget.setBackGroundImageCapInsets(cc.rect(
905-
scale9OriginX,
906-
scale9OriginY,
907-
scale9Width,
908-
scale9Height
906+
scale9OriginX,
907+
scale9OriginY,
908+
scale9Width,
909+
scale9Height
909910
));
910911
}
911912

@@ -927,7 +928,7 @@
927928
else if (horizontalType == "Align_Right")
928929
widget.setGravity(ccui.ListView.GRAVITY_RIGHT);
929930
else if (horizontalType == "Align_HorizontalCenter")
930-
widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL);
931+
widget.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL);
931932
}
932933

933934

@@ -955,7 +956,7 @@
955956

956957
var colorVector = json["ColorVector"];
957958
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
958-
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
959+
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"]));
959960
if(bgColorOpacity != null)
960961
widget.setBackGroundColorOpacity(bgColorOpacity);
961962

@@ -1130,6 +1131,8 @@
11301131
loadTexture(json["FileData"], resourcePath, function(path, type){
11311132
if(type == 0)
11321133
node = new cc.TMXTiledMap(path);
1134+
1135+
parser.generalAttributes(node, json);
11331136
});
11341137

11351138
return node;
@@ -1145,9 +1148,16 @@
11451148
var projectFile = json["FileData"];
11461149
if(projectFile != null && projectFile["Path"]){
11471150
var file = resourcePath + projectFile["Path"];
1148-
if(cc.loader.getRes(file))
1149-
return ccs._load(file);
1150-
else
1151+
if(cc.loader.getRes(file)){
1152+
var obj = ccs.load(file);
1153+
parser.generalAttributes(obj.node, json);
1154+
if(obj.action && obj.node){
1155+
obj.action.tag = obj.node.tag;
1156+
obj.node.runAction(obj.action);
1157+
obj.action.gotoFrameAndPause(0);
1158+
}
1159+
return obj.node;
1160+
} else
11511161
cc.log("%s need to be preloaded", file);
11521162
}
11531163
};
@@ -1176,6 +1186,8 @@
11761186

11771187
var currentAnimationName = json["CurrentAnimationName"];
11781188

1189+
parser.generalAttributes(node, json);
1190+
11791191
loadTexture(json["FileData"], resourcePath, function(path, type){
11801192
var plists, pngs;
11811193
var armJson = cc.loader.getRes(path);
@@ -1241,6 +1253,7 @@
12411253

12421254
var register = [
12431255
{name: "SingleNodeObjectData", handle: parser.initSingleNode},
1256+
{name: "LayerObjectData", handle: parser.initSingleNode},
12441257
{name: "SpriteObjectData", handle: parser.initSprite},
12451258
{name: "ParticleObjectData", handle: parser.initParticle},
12461259
{name: "PanelObjectData", handle: parser.initPanel},

0 commit comments

Comments
 (0)