Remove deprecated APIs and cc._Class from Actions

This commit is contained in:
pandamicro
2018-02-13 12:36:08 +08:00
parent 5795c5af3e
commit b39db499ea
6 changed files with 501 additions and 2018 deletions
+18 -27
View File
@@ -24,6 +24,8 @@
THE SOFTWARE.
****************************************************************************/
require('../core/platform/CCClass');
/**
* @module cc
*/
@@ -33,7 +35,8 @@
* !#zh Action 类是所有动作类型的基类。
* @class Action
*/
cc.Action = cc._Class.extend({
cc.Action = cc.Class({
name: 'cc.Action',
//**************Public Functions***********
@@ -185,12 +188,12 @@ cc.Action.TAG_INVALID = -1;
* @class FiniteTimeAction
* @extends Action
*/
cc.FiniteTimeAction = cc.Action.extend({
//! duration in seconds
_duration:0,
cc.FiniteTimeAction = cc.Class({
name: 'cc.FiniteTimeAction',
extends: cc.Action,
ctor:function () {
cc.Action.prototype.ctor.call(this);
//! duration in seconds
this._duration = 0;
},
@@ -259,12 +262,11 @@ cc.FiniteTimeAction = cc.Action.extend({
* @param {ActionInterval} action
* @param {Number} speed
*/
cc.Speed = cc.Action.extend({
_speed:0.0,
_innerAction:null,
cc.Speed = cc.Class({
name: 'cc.Speed',
extends: cc.Action,
ctor:function (action, speed) {
cc.Action.prototype.ctor.call(this);
this._speed = 0;
this._innerAction = null;
@@ -410,22 +412,9 @@ cc.speed = function (action, speed) {
* @class
* @extends Action
*/
cc.Follow = cc.Action.extend({
// node to follow
_followedNode:null,
// whether camera should be limited to certain area
_boundarySet:false,
// if screen size is bigger than the boundary - update not needed
_boundaryFullyCovered:false,
// fast access to the screen dimensions
_halfScreenSize:null,
_fullScreenSize:null,
_worldRect:null,
leftBoundary:0.0,
rightBoundary:0.0,
topBoundary:0.0,
bottomBoundary:0.0,
cc.Follow = cc.Class({
name: 'cc.Follow',
extends: cc.Action,
/*
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
@@ -435,11 +424,13 @@ cc.Follow = cc.Action.extend({
* @param {Rect} rect
*/
ctor:function (followedNode, rect) {
cc.Action.prototype.ctor.call(this);
// node to follow
this._followedNode = null;
// whether camera should be limited to certain area
this._boundarySet = false;
// if screen size is bigger than the boundary - update not needed
this._boundaryFullyCovered = false;
// fast access to the screen dimensions
this._halfScreenSize = null;
this._fullScreenSize = null;
+24 -23
View File
@@ -50,7 +50,7 @@
* @param {Number} t
* @return {Vec2}
*/
cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
function cardinalSplineAt (p0, p1, p2, p3, tension, t) {
var t2 = t * t;
var t3 = t2 * t;
@@ -76,7 +76,7 @@ cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
* @param {Number} pos
* @return {Array}
*/
cc.getControlPointAt = function (controlPoints, pos) {
function getControlPointAt (controlPoints, pos) {
var p = Math.min(controlPoints.length - 1, Math.max(pos, 0));
return controlPoints[p];
};
@@ -112,18 +112,17 @@ function cloneControlPoints (controlPoints) {
* //create a cc.CardinalSplineTo
* var action1 = cc.cardinalSplineTo(3, array, 0);
*/
cc.CardinalSplineTo = cc.ActionInterval.extend({
/* Array of control points */
_points:null,
_deltaT:0,
_tension:0,
_previousPosition:null,
_accumulatedDiff:null,
cc.CardinalSplineTo = cc.Class({
name: 'cc.CardinalSplineTo',
extends: cc.ActionInterval,
ctor: function (duration, points, tension) {
cc.ActionInterval.prototype.ctor.call(this);
/* Array of control points */
this._points = [];
this._deltaT = 0;
this._tension = 0;
this._previousPosition = null;
this._accumulatedDiff = null;
tension !== undefined && this.initWithDuration(duration, points, tension);
},
@@ -170,11 +169,11 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
lt = (dt - locDT * p) / locDT;
}
var newPos = cc.cardinalSplineAt(
cc.getControlPointAt(ps, p - 1),
cc.getControlPointAt(ps, p - 0),
cc.getControlPointAt(ps, p + 1),
cc.getControlPointAt(ps, p + 2),
var newPos = cardinalSplineAt(
getControlPointAt(ps, p - 1),
getControlPointAt(ps, p - 0),
getControlPointAt(ps, p + 1),
getControlPointAt(ps, p + 2),
this._tension, lt);
if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
@@ -260,13 +259,12 @@ cc.cardinalSplineTo = function (duration, points, tension) {
* //create a cc.CardinalSplineBy
* var action1 = cc.cardinalSplineBy(3, array, 0);
*/
cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
_startPosition:null,
cc.CardinalSplineBy = cc.Class({
name: 'cc.CardinalSplineBy',
extends: cc.CardinalSplineTo,
ctor:function (duration, points, tension) {
cc.CardinalSplineTo.prototype.ctor.call(this);
this._startPosition = cc.p(0, 0);
tension !== undefined && this.initWithDuration(duration, points, tension);
},
@@ -362,7 +360,9 @@ cc.cardinalSplineBy = function (duration, points, tension) {
* @example
* var action1 = cc.catmullRomTo(3, array);
*/
cc.CatmullRomTo = cc.CardinalSplineTo.extend({
cc.CatmullRomTo = cc.Class({
name: 'cc.CatmullRomTo',
extends: cc.CardinalSplineTo,
ctor: function(dt, points) {
points && this.initWithDuration(dt, points);
@@ -409,10 +409,11 @@ cc.catmullRomTo = function (dt, points) {
* @example
* var action1 = cc.catmullRomBy(3, array);
*/
cc.CatmullRomBy = cc.CardinalSplineBy.extend({
cc.CatmullRomBy = cc.Class({
name: 'cc.CatmullRomBy',
extends: cc.CardinalSplineBy,
ctor: function(dt, points) {
cc.CardinalSplineBy.prototype.ctor.call(this);
points && this.initWithDuration(dt, points);
},
File diff suppressed because it is too large Load Diff
+31 -25
View File
@@ -34,7 +34,9 @@
* @class ActionInstant
* @extends FiniteTimeAction
*/
cc.ActionInstant = cc.FiniteTimeAction.extend({
cc.ActionInstant = cc.Class({
name: 'cc.ActionInstant',
extends: cc.FiniteTimeAction,
isDone:function () {
return true;
},
@@ -72,7 +74,9 @@ cc.ActionInstant = cc.FiniteTimeAction.extend({
* @class Show
* @extends ActionInstant
*/
cc.Show = cc.ActionInstant.extend({
cc.Show = cc.Class({
name: 'cc.Show',
extends: cc.ActionInstant,
update:function (dt) {
var _renderComps = this.target.getComponentsInChildren(cc._SGComponent);
@@ -109,7 +113,9 @@ cc.show = function () {
* @class Hide
* @extends ActionInstant
*/
cc.Hide = cc.ActionInstant.extend({
cc.Hide = cc.Class({
name: 'cc.Hide',
extends: cc.ActionInstant,
update:function (dt) {
var _renderComps = this.target.getComponentsInChildren(cc._SGComponent);
@@ -146,7 +152,9 @@ cc.hide = function () {
* @class ToggleVisibility
* @extends ActionInstant
*/
cc.ToggleVisibility = cc.ActionInstant.extend({
cc.ToggleVisibility = cc.Class({
name: 'cc.ToggleVisibility',
extends: cc.ActionInstant,
update:function (dt) {
var _renderComps = this.target.getComponentsInChildren(cc._SGComponent);
@@ -188,12 +196,12 @@ cc.toggleVisibility = function () {
* // example
* var removeSelfAction = new cc.RemoveSelf(false);
*/
cc.RemoveSelf = cc.ActionInstant.extend({
_isNeedCleanUp: true,
cc.RemoveSelf = cc.Class({
name: 'cc.RemoveSelf',
extends: cc.ActionInstant,
ctor:function(isNeedCleanUp){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._isNeedCleanUp = true;
isNeedCleanUp !== undefined && this.init(isNeedCleanUp);
},
@@ -239,11 +247,11 @@ cc.removeSelf = function(isNeedCleanUp){
* @example
* var flipXAction = new cc.FlipX(true);
*/
cc.FlipX = cc.ActionInstant.extend({
_flippedX:false,
cc.FlipX = cc.Class({
name: 'cc.FlipX',
extends: cc.ActionInstant,
ctor:function(flip){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._flippedX = false;
flip !== undefined && this.initWithFlipX(flip);
},
@@ -294,13 +302,12 @@ cc.flipX = function (flip) {
* @example
* var flipYAction = new cc.FlipY(true);
*/
cc.FlipY = cc.ActionInstant.extend({
_flippedY:false,
cc.FlipY = cc.Class({
name: 'cc.FlipY',
extends: cc.ActionInstant,
ctor: function(flip){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._flippedY = false;
flip !== undefined && this.initWithFlipY(flip);
},
@@ -352,12 +359,11 @@ cc.flipY = function (flip) {
* var placeAction = new cc.Place(cc.p(200, 200));
* var placeAction = new cc.Place(200, 200);
*/
cc.Place = cc.ActionInstant.extend({
_x: 0,
_y: 0,
cc.Place = cc.Class({
name: 'cc.Place',
extends: cc.ActionInstant,
ctor:function(pos, y){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._x = 0;
this._y = 0;
@@ -425,10 +431,9 @@ cc.place = function (pos, y) {
* // CallFunc with data
* var finish = new cc.CallFunc(this.removeFromParentAndCleanup, this, true);
*/
cc.CallFunc = cc.ActionInstant.extend({
_selectorTarget:null,
_function:null,
_data:null,
cc.CallFunc = cc.Class({
name: 'cc.CallFunc',
extends: cc.ActionInstant,
/*
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
@@ -438,8 +443,9 @@ cc.CallFunc = cc.ActionInstant.extend({
* @param {*} [data=null] data for function, it accepts all data types.
*/
ctor:function(selector, selectorTarget, data){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._selectorTarget = null;
this._function = null;
this._data = null;
this.initWithFunction(selector, selectorTarget, data);
},
+134 -309
View File
@@ -46,24 +46,20 @@
* @extends FiniteTimeAction
* @param {Number} d duration in seconds
*/
cc.ActionInterval = cc.FiniteTimeAction.extend({
_elapsed:0,
_firstTick:false,
_easeList: null,
_timesForRepeat:1,
_repeatForever: false,
_repeatMethod: false,//Compatible with repeat class, Discard after can be deleted
_speed: 1,
_speedMethod: false,//Compatible with speed class, Discard after can be deleted
cc.ActionInterval = cc.Class({
name: 'cc.ActionInterval',
extends: cc.FiniteTimeAction,
ctor:function (d) {
this.MAX_VALUE = 2;
this._elapsed = 0;
this._firstTick = false;
this._easeList = null;
this._speed = 1;
this._timesForRepeat = 1;
this._repeatForever = false;
this.MAX_VALUE = 2;
this._repeatMethod = false;//Compatible with repeat class, Discard after can be deleted
this._speedMethod = false;//Compatible with repeat class, Discard after can be deleted
cc.FiniteTimeAction.prototype.ctor.call(this);
d !== undefined && this.initWithDuration(d);
},
@@ -302,15 +298,15 @@ cc.actionInterval = function (d) {
* // create sequence with array
* var seq = new cc.Sequence(actArray);
*/
cc.Sequence = cc.ActionInterval.extend({
_actions:null,
_split:null,
_last:0,
_reversed:false,
cc.Sequence = cc.Class({
name: 'cc.Sequence',
extends: cc.ActionInterval,
ctor:function (tempArray) {
cc.ActionInterval.prototype.ctor.call(this);
this._actions = [];
this._split = null;
this._last = 0;
this._reversed = false;
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
if (paramArray.length === 1) {
@@ -486,16 +482,16 @@ cc.Sequence._actionOneTwo = function (actionOne, actionTwo) {
* @example
* var rep = new cc.Repeat(cc.sequence(jump2, jump1), 5);
*/
cc.Repeat = cc.ActionInterval.extend({
_times:0,
_total:0,
_nextDt:0,
_actionInstant:false,
_innerAction:null, //CCFiniteTimeAction
cc.Repeat = cc.Class({
name: 'cc.Repeat',
extends: cc.ActionInterval,
ctor: function (action, times) {
cc.ActionInterval.prototype.ctor.call(this);
this._times = 0;
this._total = 0;
this._nextDt = 0;
this._actionInstant = false;
this._innerAction = null;
times !== undefined && this.initWithAction(action, times);
},
@@ -633,13 +629,12 @@ cc.repeat = function (action, times) {
* @example
* var rep = new cc.RepeatForever(cc.sequence(jump2, jump1), 5);
*/
cc.RepeatForever = cc.ActionInterval.extend({
_innerAction:null, //CCActionInterval
cc.RepeatForever = cc.Class({
name: 'cc.RepeatForever',
extends: cc.ActionInterval,
ctor:function (action) {
cc.ActionInterval.prototype.ctor.call(this);
this._innerAction = null;
action && this.initWithAction(action);
},
@@ -730,12 +725,11 @@ cc.repeatForever = function (action) {
* @class Spawn
* @extends ActionInterval
*/
cc.Spawn = cc.ActionInterval.extend({
_one:null,
_two:null,
cc.Spawn = cc.Class({
name: 'cc.Spawn',
extends: cc.ActionInterval,
ctor:function (tempArray) {
cc.ActionInterval.prototype.ctor.call(this);
this._one = null;
this._two = null;
@@ -871,18 +865,17 @@ cc.Spawn._actionOneTwo = function (action1, action2) {
* @example
* var rotateTo = new cc.RotateTo(2, 61.0);
*/
cc.RotateTo = cc.ActionInterval.extend({
_dstAngleX:0,
_startAngleX:0,
_diffAngleX:0,
_dstAngleY:0,
_startAngleY:0,
_diffAngleY:0,
cc.RotateTo = cc.Class({
name: 'cc.RotateTo',
extends: cc.ActionInterval,
ctor:function (duration, deltaAngleX, deltaAngleY) {
cc.ActionInterval.prototype.ctor.call(this);
this._dstAngleX = 0;
this._startAngleX = 0;
this._diffAngleX = 0;
this._dstAngleY = 0;
this._startAngleY = 0;
this._diffAngleY = 0;
deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY);
},
@@ -975,15 +968,15 @@ cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) {
* @example
* var actionBy = new cc.RotateBy(2, 360);
*/
cc.RotateBy = cc.ActionInterval.extend({
_angleX:0,
_startAngleX:0,
_angleY:0,
_startAngleY:0,
cc.RotateBy = cc.Class({
name: 'cc.RotateBy',
extends: cc.ActionInterval,
ctor: function (duration, deltaAngleX, deltaAngleY) {
cc.ActionInterval.prototype.ctor.call(this);
this._angleX = 0;
this._startAngleX = 0;
this._angleY = 0;
this._startAngleY = 0;
deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY);
},
@@ -1066,14 +1059,11 @@ cc.rotateBy = function (duration, deltaAngleX, deltaAngleY) {
* @example
* var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
*/
cc.MoveBy = cc.ActionInterval.extend({
_positionDelta:null,
_startPosition:null,
_previousPosition:null,
cc.MoveBy = cc.Class({
name: 'cc.MoveBy',
extends: cc.ActionInterval,
ctor:function (duration, deltaPos, deltaY) {
cc.ActionInterval.prototype.ctor.call(this);
this._positionDelta = cc.p(0, 0);
this._startPosition = cc.p(0, 0);
this._previousPosition = cc.p(0, 0);
@@ -1184,13 +1174,12 @@ cc.moveBy = function (duration, deltaPos, deltaY) {
* @example
* var actionBy = new cc.MoveTo(2, cc.p(80, 80));
*/
cc.MoveTo = cc.MoveBy.extend({
_endPosition:null,
cc.MoveTo = cc.Class({
name: 'cc.MoveTo',
extends: cc.MoveBy,
ctor:function (duration, position, y) {
cc.MoveBy.prototype.ctor.call(this);
this._endPosition = cc.p(0, 0);
position !== undefined && this.initWithDuration(duration, position, y);
},
@@ -1258,19 +1247,19 @@ cc.moveTo = function (duration, position, y) {
* @example
* var actionTo = new cc.SkewTo(2, 37.2, -37.2);
*/
cc.SkewTo = cc.ActionInterval.extend({
_skewX:0,
_skewY:0,
_startSkewX:0,
_startSkewY:0,
_endSkewX:0,
_endSkewY:0,
_deltaX:0,
_deltaY:0,
cc.SkewTo = cc.Class({
name: 'cc.SkewTo',
extends: cc.ActionInterval,
ctor: function (t, sx, sy) {
cc.ActionInterval.prototype.ctor.call(this);
this._skewX = 0;
this._skewY = 0;
this._startSkewX = 0;
this._startSkewY = 0;
this._endSkewX = 0;
this._endSkewY = 0;
this._deltaX = 0;
this._deltaY = 0;
sy !== undefined && this.initWithDuration(t, sx, sy);
},
@@ -1350,10 +1339,11 @@ cc.skewTo = function (t, sx, sy) {
* @param {Number} sx skew in degrees for X axis
* @param {Number} sy skew in degrees for Y axis
*/
cc.SkewBy = cc.SkewTo.extend({
cc.SkewBy = cc.Class({
name: 'cc.SkewBy',
extends: cc.SkewTo,
ctor: function(t, sx, sy) {
cc.SkewTo.prototype.ctor.call(this);
sy !== undefined && this.initWithDuration(t, sx, sy);
},
@@ -1430,18 +1420,16 @@ cc.skewBy = function (t, sx, sy) {
* var actionBy = new cc.JumpBy(2, cc.p(300, 0), 50, 4);
* var actionBy = new cc.JumpBy(2, 300, 0, 50, 4);
*/
cc.JumpBy = cc.ActionInterval.extend({
_startPosition:null,
_delta:null,
_height:0,
_jumps:0,
_previousPosition:null,
cc.JumpBy = cc.Class({
name: 'cc.JumpBy',
extends: cc.ActionInterval,
ctor:function (duration, position, y, height, jumps) {
cc.ActionInterval.prototype.ctor.call(this);
this._startPosition = cc.p(0, 0);
this._previousPosition = cc.p(0, 0);
this._delta = cc.p(0, 0);
this._height = 0;
this._jumps = 0;
height !== undefined && this.initWithDuration(duration, position, y, height, jumps);
},
@@ -1561,13 +1549,12 @@ cc.jumpBy = function (duration, position, y, height, jumps) {
* var actionTo = new cc.JumpTo(2, cc.p(300, 0), 50, 4);
* var actionTo = new cc.JumpTo(2, 300, 0, 50, 4);
*/
cc.JumpTo = cc.JumpBy.extend({
_endPosition:null,
cc.JumpTo = cc.Class({
name: 'cc.JumpTo',
extends: cc.JumpBy,
ctor:function (duration, position, y, height, jumps) {
cc.JumpBy.prototype.ctor.call(this);
this._endPosition = cc.p(0, 0);
height !== undefined && this.initWithDuration(duration, position, y, height, jumps);
},
/*
@@ -1656,17 +1643,14 @@ cc.bezierAt = function (a, b, c, d, t) {
* var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
* var bezierForward = new cc.BezierBy(3, bezier);
*/
cc.BezierBy = cc.ActionInterval.extend({
_config:null,
_startPosition:null,
_previousPosition:null,
cc.BezierBy = cc.Class({
name: 'cc.BezierBy',
extends: cc.ActionInterval,
ctor:function (t, c) {
cc.ActionInterval.prototype.ctor.call(this);
this._config = [];
this._startPosition = cc.p(0, 0);
this._previousPosition = cc.p(0, 0);
c && this.initWithDuration(t, c);
},
@@ -1783,11 +1767,11 @@ cc.bezierBy = function (t, c) {
* var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
* var bezierTo = new cc.BezierTo(2, bezier);
*/
cc.BezierTo = cc.BezierBy.extend({
_toConfig:null,
cc.BezierTo = cc.Class({
name: 'cc.BezierTo',
extends: cc.BezierBy,
ctor:function (t, c) {
cc.BezierBy.prototype.ctor.call(this);
this._toConfig = [];
c && this.initWithDuration(t, c);
},
@@ -1855,18 +1839,19 @@ cc.bezierTo = function (t, c) {
* // It scales to 0.5 in x and 2 in Y
* var actionTo = new cc.ScaleTo(2, 0.5, 2);
*/
cc.ScaleTo = cc.ActionInterval.extend({
_scaleX:1,
_scaleY:1,
_startScaleX:1,
_startScaleY:1,
_endScaleX:0,
_endScaleY:0,
_deltaX:0,
_deltaY:0,
cc.ScaleTo = cc.Class({
name: 'cc.ScaleTo',
extends: cc.ActionInterval,
ctor:function (duration, sx, sy) {
cc.ActionInterval.prototype.ctor.call(this);
this._scaleX = 1;
this._scaleY = 1;
this._startScaleX = 1;
this._startScaleY = 1;
this._endScaleX = 0;
this._endScaleY = 0;
this._deltaX = 0;
this._deltaY = 0;
sx !== undefined && this.initWithDuration(duration, sx, sy);
},
@@ -1935,7 +1920,10 @@ cc.scaleTo = function (duration, sx, sy) { //function overload
* @class ScaleBy
* @extends ScaleTo
*/
cc.ScaleBy = cc.ScaleTo.extend({
cc.ScaleBy = cc.Class({
name: 'cc.ScaleBy',
extends: cc.ScaleTo,
startWithTarget:function (target) {
cc.ScaleTo.prototype.startWithTarget.call(this, target);
this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
@@ -1985,12 +1973,13 @@ cc.scaleBy = function (duration, sx, sy) {
* @example
* var action = new cc.Blink(2, 10);
*/
cc.Blink = cc.ActionInterval.extend({
_times:0,
_originalState:false,
cc.Blink = cc.Class({
name: 'cc.Blink',
extends: cc.ActionInterval,
ctor:function (duration, blinks) {
cc.ActionInterval.prototype.ctor.call(this);
this._times = 0;
this._originalState = false;
blinks !== undefined && this.initWithDuration(duration, blinks);
},
@@ -2065,12 +2054,13 @@ cc.blink = function (duration, blinks) {
* @example
* var action = new cc.FadeTo(1.0, 0);
*/
cc.FadeTo = cc.ActionInterval.extend({
_toOpacity:0,
_fromOpacity:0,
cc.FadeTo = cc.Class({
name: 'cc.FadeTo',
extends: cc.ActionInterval,
ctor:function (duration, opacity) {
cc.ActionInterval.prototype.ctor.call(this);
this._toOpacity = 0;
this._fromOpacity = 0;
opacity !== undefined && this.initWithDuration(duration, opacity);
},
@@ -2130,13 +2120,14 @@ cc.fadeTo = function (duration, opacity) {
* @extends FadeTo
* @param {Number} duration duration in seconds
*/
cc.FadeIn = cc.FadeTo.extend({
_reverseAction: null,
cc.FadeIn = cc.Class({
name: 'cc.FadeIn',
extends: cc.FadeTo,
ctor:function (duration) {
cc.FadeTo.prototype.ctor.call(this);
if (duration == null)
duration = 0;
this._reverseAction = null;
this.initWithDuration(duration, 255);
},
@@ -2183,12 +2174,14 @@ cc.fadeIn = function (duration) {
* @extends FadeTo
* @param {Number} duration duration in seconds
*/
cc.FadeOut = cc.FadeTo.extend({
cc.FadeOut = cc.Class({
name: 'cc.FadeOut',
extends: cc.FadeTo,
ctor:function (duration) {
cc.FadeTo.prototype.ctor.call(this);
if (duration == null)
duration = 0;
this._reverseAction = null;
this.initWithDuration(duration, 0);
},
@@ -2234,12 +2227,11 @@ cc.fadeOut = function (d) {
* @example
* var action = new cc.TintTo(2, 255, 0, 255);
*/
cc.TintTo = cc.ActionInterval.extend({
_to:null,
_from:null,
cc.TintTo = cc.Class({
name: 'cc.TintTo',
extends: cc.ActionInterval,
ctor:function (duration, red, green, blue) {
cc.ActionInterval.prototype.ctor.call(this);
this._to = cc.color(0, 0, 0);
this._from = cc.color(0, 0, 0);
@@ -2325,17 +2317,17 @@ cc.tintTo = function (duration, red, green, blue) {
* @example
* var action = new cc.TintBy(2, -127, -255, -127);
*/
cc.TintBy = cc.ActionInterval.extend({
_deltaR:0,
_deltaG:0,
_deltaB:0,
_fromR:0,
_fromG:0,
_fromB:0,
cc.TintBy = cc.Class({
name: 'cc.TintBy',
extends: cc.ActionInterval,
ctor:function (duration, deltaRed, deltaGreen, deltaBlue) {
cc.ActionInterval.prototype.ctor.call(this);
this._deltaR = 0;
this._deltaG = 0;
this._deltaB = 0;
this._fromR = 0;
this._fromG = 0;
this._fromB = 0;
deltaBlue !== undefined && this.initWithDuration(duration, deltaRed, deltaGreen, deltaBlue);
},
@@ -2412,7 +2404,10 @@ cc.tintBy = function (duration, deltaRed, deltaGreen, deltaBlue) {
* @class DelayTime
* @extends ActionInterval
*/
cc.DelayTime = cc.ActionInterval.extend({
cc.DelayTime = cc.Class({
name: 'cc.DelayTime',
extends: cc.ActionInterval,
update:function (dt) {},
reverse:function () {
@@ -2457,13 +2452,12 @@ cc.delayTime = function (d) {
* @example
* var reverse = new cc.ReverseTime(this);
*/
cc.ReverseTime = cc.ActionInterval.extend({
_other:null,
cc.ReverseTime = cc.Class({
name: 'cc.ReverseTime',
extends: cc.ActionInterval,
ctor:function (action) {
cc.ActionInterval.prototype.ctor.call(this);
this._other = null;
action && this.initWithAction(action);
},
@@ -2527,176 +2521,6 @@ cc.reverseTime = function (action) {
return new cc.ReverseTime(action);
};
/*
* This API is deprecated, will be replaced by new API from {{#crossLink "Animation"}}cc.Animation{{/crossLink}}
* Animates a sprite given the name of an Animation
* @class Animate
* @extends ActionInterval
* @param {SpriteFrameAnimation} animation
* @example
* // create the animation with animation
* var anim = new cc.Animate(dance_grey);
*/
cc.Animate = cc.ActionInterval.extend({
_animation:null,
_nextFrame:0,
_origFrame:null,
_executedLoops:0,
_splitTimes: null,
_currFrameIndex:0,
ctor:function (animation) {
cc.ActionInterval.prototype.ctor.call(this);
this._splitTimes = [];
animation && this.initWithAnimation(animation);
},
/*
* @return {SpriteFrameAnimation}
*/
getAnimation:function () {
return this._animation;
},
/*
* @param {SpriteFrameAnimation} animation
*/
setAnimation:function (animation) {
this._animation = animation;
},
/*
* Gets the index of sprite frame currently displayed.
* @return {Number}
*/
getCurrentFrameIndex: function () {
return this._currFrameIndex;
},
/*
* @param {SpriteFrameAnimation} animation
* @return {Boolean}
*/
initWithAnimation:function (animation) {
if(!animation)
throw new Error(cc._getError(1030));
var singleDuration = animation.getDuration();
if (this.initWithDuration(singleDuration * animation.getLoops())) {
this._nextFrame = 0;
this.setAnimation(animation);
this._origFrame = null;
this._executedLoops = 0;
var locTimes = this._splitTimes;
locTimes.length = 0;
var accumUnitsOfTime = 0;
var newUnitOfTimeValue = singleDuration / animation.getTotalDelayUnits();
var frames = animation.getFrames();
cc.js.array.verifyType(frames, cc.AnimationFrame);
for (var i = 0; i < frames.length; i++) {
var frame = frames[i];
var value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
accumUnitsOfTime += frame.getDelayUnits();
locTimes.push(value);
}
return true;
}
return false;
},
clone:function () {
var action = new cc.Animate();
this._cloneDecoration(action);
action.initWithAnimation(this._animation.clone());
return action;
},
startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
if (this._animation.getRestoreOriginalFrame())
this._origFrame = target.getSpriteFrame();
this._nextFrame = 0;
this._executedLoops = 0;
},
update:function (dt) {
dt = this._computeEaseTime(dt);
// if t==1, ignore. Animation should finish with t==1
if (dt < 1.0) {
dt *= this._animation.getLoops();
// new loop? If so, reset frame counter
var loopNumber = 0 | dt;
if (loopNumber > this._executedLoops) {
this._nextFrame = 0;
this._executedLoops++;
}
// new t for animations
dt = dt % 1.0;
}
var frames = this._animation.getFrames();
var numberOfFrames = frames.length, locSplitTimes = this._splitTimes;
for (var i = this._nextFrame; i < numberOfFrames; i++) {
if (locSplitTimes[i] <= dt) {
_currFrameIndex = i;
this.target.setSpriteFrame(frames[_currFrameIndex].getSpriteFrame());
this._nextFrame = i + 1;
} else {
// Issue 1438. Could be more than one frame per tick, due to low frame rate or frame delta < 1/FPS
break;
}
}
},
reverse:function () {
var locAnimation = this._animation;
var oldArray = locAnimation.getFrames();
var newArray = [];
cc.js.array.verifyType(oldArray, cc.AnimationFrame);
if (oldArray.length > 0) {
for (var i = oldArray.length - 1; i >= 0; i--) {
var element = oldArray[i];
if (!element)
break;
newArray.push(element.clone());
}
}
var newAnim = new cc.SpriteFrameAnimation(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops());
newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame());
var action = new cc.Animate(newAnim);
this._cloneDecoration(action);
this._reverseEaseList(action);
return action;
},
stop:function () {
if (this._animation.getRestoreOriginalFrame() && this.target)
this.target.setSpriteFrame(this._origFrame);
cc.Action.prototype.stop.call(this);
}
});
/*
* create the animate with animation
* @method animate
* @param {SpriteFrameAnimation} animation
* @return {ActionInterval}
* @example
* // example
* // create the animation with animation
* var anim = cc.animate(dance_grey);
*/
cc.animate = function (animation) {
return new cc.Animate(animation);
};
/*
* <p>
* Overrides the target of an action so that it always runs on the target<br/>
@@ -2707,12 +2531,13 @@ cc.animate = function (animation) {
* @param {Node} target
* @param {FiniteTimeAction} action
*/
cc.TargetedAction = cc.ActionInterval.extend({
_action:null,
_forcedTarget:null,
cc.TargetedAction = cc.Class({
name: 'cc.TargetedAction',
extends: cc.ActionInterval,
ctor: function (target, action) {
cc.ActionInterval.prototype.ctor.call(this);
this._action = null;
this._forcedTarget = null;
action && this.initWithTarget(target, action);
},
+3
View File
@@ -24,6 +24,8 @@
THE SOFTWARE.
****************************************************************************/
require('../core/platform/CCClass');
/*
* @class HashElement
* @constructor
@@ -61,6 +63,7 @@ cc.ActionManager = function () {
this._hashTargets = {};
this._arrayTargets = [];
this._currentTarget = null;
this.__instanceId = cc.ClassManager.getNewInstanceId();
};
cc.ActionManager.prototype = {
constructor: cc.ActionManager,