diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 04c1dfa450..755cbbd578 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -99,9 +99,9 @@ ccs.FrameEaseType = { Circ_EaseOut : 20, Circ_EaseInOut : 21, - Elastic_EaesIn : 22, - Elastic_EaesOut : 23, - Elastic_EaesInOut : 24, + Elastic_EaseIn : 22, + Elastic_EaseOut : 23, + Elastic_EaseInOut : 24, Back_EaseIn : 25, Back_EaseOut : 26, @@ -109,7 +109,9 @@ ccs.FrameEaseType = { Bounce_EaseIn : 28, Bounce_EaseOut : 29, - Bounce_EaseInOut : 30 + Bounce_EaseInOut : 30, + + TWEEN_EASING_MAX: 1000 }; @@ -227,13 +229,13 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ case ccs.FrameEaseType.Circ_EaseInOut: resultAction = action.easing(cc.easeCircleActionInOut()); break; - case ccs.FrameEaseType.Elastic_EaesIn: + case ccs.FrameEaseType.Elastic_EaseIn: resultAction = action.easing(cc.easeElasticIn()); break; - case ccs.FrameEaseType.Elastic_EaesOut: + case ccs.FrameEaseType.Elastic_EaseOut: resultAction = action.easing(cc.easeElasticOut()); break; - case ccs.FrameEaseType.Elastic_EaesInOut: + case ccs.FrameEaseType.Elastic_EaseInOut: resultAction = action.easing(cc.easeElasticInOut()); break; case ccs.FrameEaseType.Back_EaseIn: diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index d7ff403256..dfe69dc51f 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -65,7 +65,7 @@ deferred: function(json, resourcePath, action, file){ var animationlist = json["Content"]["Content"]["AnimationList"]; var length = animationlist ? animationlist.length : 0; - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; i++){ var animationdata = animationlist[i]; var info = { name: null, startIndex: null, endIndex: null }; info.name = animationdata["Name"]; @@ -220,7 +220,7 @@ }, { name: "ActionValue", - handle: function(options){ + handle: function (options) { var frame = new ccs.InnerActionFrame(); var innerActionType = options["InnerActionType"]; @@ -229,6 +229,10 @@ var singleFrameIndex = options["SingleFrameIndex"]; + var frameIndex = options["FrameIndex"]; + if(frameIndex !== undefined) + frame.setFrameIndex(frameIndex); + frame.setInnerActionType(ccs.InnerActionType[innerActionType]); frame.setSingleFrameIndex(singleFrameIndex); @@ -240,6 +244,18 @@ } ]; + var loadEasingDataWithFlatBuffers = function(frame, options){ + var type = options["Type"]; + frame.setTweenType(type); + var points = options["Points"]; + if(points){ + points = points.map(function(p){ + return cc.p(p["X"], p["Y"]); + }); + frame.setEasingParams(points); + } + }; + frameList.forEach(function(item){ parser.registerParser(item.name, function(options, resourcePath){ var timeline = new ccs.Timeline(); @@ -252,6 +268,10 @@ frame.setFrameIndex(frameData["FrameIndex"]); var tween = frameData["Tween"] != null ? frameData["Tween"] : true; frame.setTween(tween); + //https://github.com/cocos2d/cocos2d-x/pull/11388/files + var easingData = frameData["EasingData"]; + if(easingData) + loadEasingDataWithFlatBuffers(frame, easingData); timeline.addFrame(frame); }); } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 542fb9b5eb..cae39cfa3d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -111,7 +111,13 @@ node.setTag(json["Tag"] || 0); - node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"] || 0)); + var actionTag = json["ActionTag"] || 0; + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + node.setUserObject(extensionData); node.setCascadeColorEnabled(true); node.setCascadeOpacityEnabled(true); @@ -175,6 +181,16 @@ } }); + var blendData = json["BlendFunc"]; + if(json["BlendFunc"]) { + var blendFunc = cc.BlendFunc.ALPHA_PREMULTIPLIED; + if (blendData["Src"] !== undefined) + blendFunc.src = blendData["Src"]; + if (blendData["Dst"] !== undefined) + blendFunc.dst = blendData["Dst"]; + node.setBlendFunc(blendFunc); + } + if(json["FlipX"]) node.setFlippedX(true); if(json["FlipY"]) @@ -203,6 +219,16 @@ node = new cc.ParticleSystem(path); self.generalAttributes(node, json); !cc.sys.isNative && node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); + + var blendData = json["BlendFunc"]; + if(json["BlendFunc"]){ + var blendFunc = cc.BlendFunc.ALPHA_PREMULTIPLIED; + if(blendData["Src"] !== undefined) + blendFunc.src = blendData["Src"]; + if(blendData["Dst"] !== undefined) + blendFunc.dst = blendData["Dst"]; + node.setBlendFunc(new cc.BlendFunc()); + } }); return node; }; @@ -227,7 +253,12 @@ var actionTag = json["ActionTag"] || 0; widget.setActionTag(actionTag); - widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + widget.setUserObject(extensionData); var rotationSkewX = json["RotationSkewX"]; if (rotationSkewX) @@ -492,6 +523,16 @@ } widget.setTextVerticalAlignment(v_alignment); + if(json["OutlineEnabled"] && json["OutlineColor"]) + widget.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); + + if(json["ShadowEnabled"] && json["ShadowColor"]) + widget.enableShadow( + getColor(json["ShadowColor"]), + cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), + json["ShadowBlurRadius"] || 0 + ); + //todo check it var isCustomSize = json["IsCustomSize"]; if(isCustomSize != null) @@ -1157,6 +1198,9 @@ parser.generalAttributes(obj.node, json); if(obj.action && obj.node){ obj.action.tag = obj.node.tag; + var InnerActionSpeed = json["InnerActionSpeed"]; + if(InnerActionSpeed !== undefined) + obj.action.setTimeSpeed(InnerActionSpeed); obj.node.runAction(obj.action); obj.action.gotoFrameAndPause(0); } @@ -1245,7 +1289,8 @@ var r = json["R"] != null ? json["R"] : 255; var g = json["G"] != null ? json["G"] : 255; var b = json["B"] != null ? json["B"] : 255; - return cc.color(r, g, b); + var a = json["A"] != null ? json["A"] : 255; + return cc.color(r, g, b, a); }; var setContentSize = function(node, size){ diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 0bada129ee..3712238878 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -60,6 +60,29 @@ ccs.ActionTimelineData = ccs.Class.extend({ }); +ccs.ObjectExtensionData = ccs.Class.extend({ + + _customProperty: null, + _timelineData: null, + + ctor: function(){ + this._timelineData = new ccs.ActionTimelineData(0); + return true; + }, + + setActionTag: function(actionTag){ + this._timelineData.setActionTag(actionTag); + }, + + getActionTag: function(){ + return this._timelineData.getActionTag(); + } +}); + +ccs.ObjectExtensionData.create = function(){ + return new ccs.ObjectExtensionData(); +}; + /** * Create new ActionTimelineData. * diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 460bbf86d2..b76f1e1328 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -33,12 +33,15 @@ ccs.Frame = ccs.Class.extend({ _tween: null, _timeline: null, _node: null, + _tweenType: null, + _easingParam: null, ctor: function(){ this._frameIndex = 0; this._tween = true; this._timeline = null; this._node = null; + this._easingParam = []; }, _emitEvent: function(){ @@ -50,6 +53,8 @@ ccs.Frame = ccs.Class.extend({ _cloneProperty: function(frame){ this._frameIndex = frame.getFrameIndex(); this._tween = frame.isTween(); + this._tweenType = frame.getTweenType(); + this.setEasingParams(frame.getEasingParams()); }, /** @@ -131,6 +136,15 @@ ccs.Frame = ccs.Class.extend({ * @param {number} percent */ apply: function(percent){ + if(!this._tween) + return; + if(this._tweenType !== ccs.FrameEaseType.TWEEN_EASING_MAX && this._tweenType !== ccs.FrameEaseType.Linear) + percent = this.tweenPercent(percent); + this._onApply(percent); + }, + + _onApply: function(percent){ + }, /** @@ -140,6 +154,140 @@ ccs.Frame = ccs.Class.extend({ * @return {ccs.Frame} */ clone: function(){ // = 0 + }, + + tweenPercent: function(percent){ + return this._tweenTo(percent, this._tweenType, this._easingParam); + }, + + setEasingParams: function(easingParams){ + if(easingParams){ + this._easingParam.length = 0; + for(var i=0; i