Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/cocostudio/loader/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ ccs.load = function(file){

object.node = ccs._load(file);
object.action = ccs._load(file, "action");
if(object.action && object.action.tag === -1 && object.node)
object.action.tag = object.node.tag;
return object;
};

Expand Down
36 changes: 36 additions & 0 deletions extensions/cocostudio/loader/parsers/action-2.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

action.setDuration(json["Duration"]);
action.setTimeSpeed(json["Speed"] || 1);

//The process of analysis
var timelines = json["Timelines"];
timelines.forEach(function(timeline){
Expand All @@ -59,6 +60,21 @@
cache[file] = action;
cache[file].retain();
return action.clone();
},

deferred: function(json, resourcePath, action, file){
if(cc.sys.isNative) {
var animationlist = json["Content"]["Content"]["AnimationList"];
var length = animationlist ? animationlist.length : 0;
for (var i = 0; i < length; i++) {
var animationdata = animationlist[i];
var info = { name: null, startIndex: null, endIndex: null };
info.name = animationdata["Name"];
info.startIndex = animationdata["StartIndex"];
info.endIndex = animationdata["EndIndex"];
action.addAnimationInfo(info);
}
}
}

});
Expand Down Expand Up @@ -201,6 +217,26 @@
var frame = new ccs.ZOrderFrame();
var zorder = options["Value"];
frame.setZOrder(zorder);
return frame;
}
},
{
name: "ActionValue",
handle: function(options){

var frame = new ccs.InnerActionFrame();
var innerActionType = options["InnerActionType"];

var currentAnimationFrame = options["CurrentAniamtionName"];

var singleFrameIndex = options["SingleFrameIndex"];

frame.setInnerActionType(ccs.InnerActionType[innerActionType]);
frame.setSingleFrameIndex(singleFrameIndex);

frame.setEnterWithName(true);
frame.setAnimationName(currentAnimationFrame);

return frame;
}
}
Expand Down
55 changes: 34 additions & 21 deletions extensions/cocostudio/loader/parsers/timelineParser-2.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@

var scale = json["Scale"];
if(scale != null){
widget.setScaleX(scale["ScaleX"] || 1);
widget.setScaleY(scale["ScaleY"] || 1);
var scaleX = getParam(scale["ScaleX"], 1);
var scaleY = getParam(scale["ScaleY"], 1);
widget.setScaleX(scaleX);
widget.setScaleY(scaleY);
}

var anchorPoint = json["AnchorPoint"];
Expand Down Expand Up @@ -372,7 +374,7 @@

this.widgetAttributes(widget, json);

var clipEnabled = json["ClipAple"];
var clipEnabled = json["ClipAble"];
if(clipEnabled != null)
widget.setClippingEnabled(clipEnabled);

Expand All @@ -387,7 +389,7 @@
if(backGroundScale9Enabled != null)
widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled);

var opacity = json["Alpha"] || 255;
var opacity = getParam(json["Alpha"], 255);
widget.setOpacity(opacity);

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

var clipEnabled = json["ClipAble"];
if(clipEnabled)
widget.setClippingEnabled(true);
widget.setClippingEnabled(clipEnabled);

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

var colorVector = json["ColorVector"];
if(colorVector){
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"] || 1, colorVector["ScaleY"] || 1));
var colorVectorX = getParam(colorVector["ScaleX"], 1);
var colorVectorY = getParam(colorVector["ScaleY"], 1);
widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY));
}

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

var innerNodeSize = json["InnerNodeSize"];
var innerSize = cc.size(
innerNodeSize["width"] || 0,
innerNodeSize["height"] || 0
innerNodeSize["Width"] || 0,
innerNodeSize["Height"] || 0
);
widget.setInnerContainerSize(innerSize);

Expand Down Expand Up @@ -822,9 +825,8 @@

this.widgetAttributes(widget, json);

var clipEnabled = json["ClipAble"];
if(clipEnabled)
widget.setClippingEnabled(true);
var clipEnabled = json["ClipAble"] || false;
widget.setClippingEnabled(clipEnabled);

var backGroundScale9Enabled = json["Scale9Enable"];
if(backGroundScale9Enabled){
Expand Down Expand Up @@ -859,7 +861,7 @@

var colorVector = json["ColorVector"];
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"]));
if(bgColorOpacity != null)
widget.setBackGroundColorOpacity(bgColorOpacity);

Expand All @@ -885,9 +887,8 @@

this.widgetAttributes(widget, json);

var clipEnabled = json["ClipAble"];
if(clipEnabled)
widget.setClippingEnabled(true);
var clipEnabled = json["ClipAble"] || false;
widget.setClippingEnabled(clipEnabled);

var colorType = getParam(json["ComboBoxIndex"], 0);
widget.setBackGroundColorType(colorType);
Expand Down Expand Up @@ -927,7 +928,7 @@
else if (horizontalType == "Align_Right")
widget.setGravity(ccui.ListView.GRAVITY_RIGHT);
else if (horizontalType == "Align_HorizontalCenter")
widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL);
widget.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL);
}


Expand Down Expand Up @@ -955,7 +956,7 @@

var colorVector = json["ColorVector"];
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"]));
if(bgColorOpacity != null)
widget.setBackGroundColorOpacity(bgColorOpacity);

Expand Down Expand Up @@ -1130,6 +1131,8 @@
loadTexture(json["FileData"], resourcePath, function(path, type){
if(type == 0)
node = new cc.TMXTiledMap(path);

parser.generalAttributes(node, json);
});

return node;
Expand All @@ -1145,9 +1148,16 @@
var projectFile = json["FileData"];
if(projectFile != null && projectFile["Path"]){
var file = resourcePath + projectFile["Path"];
if(cc.loader.getRes(file))
return ccs._load(file);
else
if(cc.loader.getRes(file)){
var obj = ccs.load(file);
parser.generalAttributes(obj.node, json);
if(obj.action && obj.node){
obj.action.tag = obj.node.tag;
obj.node.runAction(obj.action);
obj.action.gotoFrameAndPause(0);
}
return obj.node;
} else
cc.log("%s need to be preloaded", file);
}
};
Expand Down Expand Up @@ -1176,6 +1186,8 @@

var currentAnimationName = json["CurrentAnimationName"];

parser.generalAttributes(node, json);

loadTexture(json["FileData"], resourcePath, function(path, type){
var plists, pngs;
var armJson = cc.loader.getRes(path);
Expand Down Expand Up @@ -1241,6 +1253,7 @@

var register = [
{name: "SingleNodeObjectData", handle: parser.initSingleNode},
{name: "LayerObjectData", handle: parser.initSingleNode},
{name: "SpriteObjectData", handle: parser.initSprite},
{name: "ParticleObjectData", handle: parser.initParticle},
{name: "PanelObjectData", handle: parser.initPanel},
Expand Down
2 changes: 1 addition & 1 deletion extensions/cocostudio/timeline/ActionTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ ccs.ActionTimeline = cc.Action.extend({
}

this._time += delta * this._timeSpeed;
this._currentFrame = this._time / this._frameInternal;
this._currentFrame = this._time / this._frameInternal | 0;

this._stepToFrame(this._currentFrame);

Expand Down
62 changes: 61 additions & 1 deletion extensions/cocostudio/timeline/Frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@ ccs.InnerActionFrame = ccs.Frame.extend({
_innerActionType: null,
_startFrameIndex: null,

_endFrameIndex:0,
_singleFrameIndex: 0,
_enterWithName: false,
_animationName: "",

ctor: function(){
ccs.Frame.prototype.ctor.call(this);

Expand All @@ -871,7 +876,62 @@ ccs.InnerActionFrame = ccs.Frame.extend({
* @param {ccs.Frame} nextFrame
*/
onEnter: function(nextFrame){
//override
var innerActiontimeline = this._node.getActionByTag(this._node.getTag());
if (/*ccs.InnerActionType.SingleFrame*/"SingleFrame" == this._innerActionType){
innerActiontimeline.gotoFrameAndPause(this._singleFrameIndex);
return;
}

var innerStart = this._startFrameIndex;
var innerEnd = this._endFrameIndex;
if (this._enterWithName){
if (this._animationName == "-- ALL --"){
innerStart = 0;
innerEnd = innerActiontimeline.getDuration();
} else if(innerActiontimeline.IsAnimationInfoExists(this._animationName)) {
var info = innerActiontimeline.getAnimationInfo(this._animationName);
innerStart = info.startIndex;
innerEnd = info.endIndex;
}else{
cc.log("Animation %s not exists!", this._animationName);
}
}

var duration = this._timeline.getActionTimeline().getDuration();
var odddiff = duration - this._frameIndex - innerEnd + innerStart;
if (odddiff < 0){
innerEnd += odddiff;
}

if (ccs.InnerActionType.NoLoopAction == this._innerActionType){
innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, false);
}else if (ccs.InnerActionType.LoopAction == this._innerActionType){
innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, true);
}
},

setAnimationName: function(animationName){
if(!this._enterWithName){
cc.log(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
}else{
this._animationName = animationName;
}
},

setSingleFrameIndex: function(frameIndex){
this._singleFrameIndex = frameIndex;
},

getSingleFrameIndex: function(){
return this._startFrameIndex;
},

setEnterWithName: function(isEnterWithName){
this._enterWithName = isEnterWithName;
},

getEnterWithName: function(){
return this._enterWithName;
},

/**
Expand Down
4 changes: 1 addition & 3 deletions extensions/cocostudio/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ ccs.Timeline = ccs.Class.extend({
* @param {cc.Node} node
*/
setNode: function(node){
for (var i=0; i<this._frames.length; i++)
{
for (var i=0; i<this._frames.length; i++){
var frame = this._frames[i];
frame.setNode(node);
}

},

/**
Expand Down