diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js
index 57e49ea6b7..dc037306ed 100644
--- a/cocos2d/actions/CCAction.js
+++ b/cocos2d/actions/CCAction.js
@@ -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.
@@ -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;
diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js
index 63fb9b1dfe..6d02ed9c2e 100644
--- a/cocos2d/actions/CCActionCatmullRom.js
+++ b/cocos2d/actions/CCActionCatmullRom.js
@@ -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);
},
diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js
index 809b55085d..81399ac8d1 100644
--- a/cocos2d/actions/CCActionEase.js
+++ b/cocos2d/actions/CCActionEase.js
@@ -28,169 +28,6 @@
* @module cc
*/
-/**
- * !#en Base class for Easing actions.
- * !#zh 所有缓动动作基类,用于修饰 ActionInterval。
- * @class ActionEase
- * @extends ActionInterval
- * @param {ActionInterval} action
- */
-cc.ActionEase = cc.ActionInterval.extend({
- _inner:null,
-
- ctor: function (action) {
- cc.ActionInterval.prototype.ctor.call(this);
- action && this.initWithAction(action);
- },
-
- /**
- * initializes the action
- *
- * @param {ActionInterval} action
- * @return {Boolean}
- */
- initWithAction:function (action) {
- if(!action)
- throw new Error(cc._getError(1023));
-
- if (this.initWithDuration(action.getDuration())) {
- this._inner = action;
- return true;
- }
- return false;
- },
-
- clone:function(){
- var action = new cc.ActionEase();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
- this._inner.startWithTarget(this.target);
- },
-
- stop:function () {
- this._inner.stop();
- cc.ActionInterval.prototype.stop.call(this);
- },
-
- update:function (dt) {
- this._inner.update(dt);
- },
-
- reverse:function () {
- return new cc.ActionEase(this._inner.reverse());
- },
-
- /**
- * Get inner Action.
- *
- * @return {ActionInterval}
- */
- getInnerAction:function(){
- return this._inner;
- }
-});
-
-cc.actionEase = function (action) {
- return new cc.ActionEase(action);
-};
-
-/**
- * !#en Base class for Easing actions with rate parameters
- * !#zh 拥有速率属性的缓动动作基类。
- * @class EaseRateAction
- * @extends ActionEase
- * @param {ActionInterval} action
- * @param {Number} rate
- */
-cc.EaseRateAction = cc.ActionEase.extend({
- _rate:0,
-
- ctor: function(action, rate){
- cc.ActionEase.prototype.ctor.call(this);
-
- rate !== undefined && this.initWithAction(action, rate);
- },
-
- /**
- * set rate value for the actions
- * @param {Number} rate
- */
- setRate:function (rate) {
- this._rate = rate;
- },
-
- /** get rate value for the actions
- * @return {Number}
- */
- getRate:function () {
- return this._rate;
- },
-
- /**
- * Initializes the action with the inner action and the rate parameter
- * @param {ActionInterval} action
- * @param {Number} rate
- * @return {Boolean}
- */
- initWithAction:function (action, rate) {
- if (cc.ActionEase.prototype.initWithAction.call(this, action)) {
- this._rate = rate;
- return true;
- }
- return false;
- },
-
- clone:function(){
- var action = new cc.EaseRateAction();
- action.initWithAction(this._inner.clone(), this._rate);
- return action;
- },
-
- reverse:function () {
- return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate);
- }
-});
-
-cc.easeRateAction = function (action, rate) {
- return new cc.EaseRateAction(action, rate);
-};
-
-/**
- * @module cc
- */
-
-/*
- * cc.EaseIn action with a rate. From slow to fast.
- *
- * @class EaseIn
- * @extends EaseRateAction
- *
- * @deprecated since v3.0 please use action.easing(cc.easeIn(3));
- *
- * @example
- * action.easing(cc.easeIn(3.0));
- */
-cc.EaseIn = cc.EaseRateAction.extend({
-
- update:function (dt) {
- this._inner.update(Math.pow(dt, this._rate));
- },
-
- reverse:function () {
- return new cc.EaseIn(this._inner.reverse(), 1 / this._rate);
- },
-
- clone:function(){
- var action = new cc.EaseIn();
- action.initWithAction(this._inner.clone(), this._rate);
- return action;
- }
-});
-
/**
* !#en
* Creates the action easing object with the rate parameter.
@@ -214,33 +51,6 @@ cc.easeIn = function (rate) {
};
};
-/*
- * cc.EaseOut action with a rate. From fast to slow.
- *
- * @class EaseOut
- * @extends EaseRateAction
- *
- * @deprecated since v3.0 please use action.easing(cc.easeOut(3))
- *
- * @example
- * action.easing(cc.easeOut(3.0));
- */
-cc.EaseOut = cc.EaseRateAction.extend({
- update:function (dt) {
- this._inner.update(Math.pow(dt, 1 / this._rate));
- },
-
- reverse:function () {
- return new cc.EaseOut(this._inner.reverse(), 1 / this._rate);
- },
-
- clone:function(){
- var action = new cc.EaseOut();
- action.initWithAction(this._inner.clone(),this._rate);
- return action;
- }
-});
-
/**
* !#en
* Creates the action easing object with the rate parameter.
@@ -264,37 +74,6 @@ cc.easeOut = function (rate) {
};
};
-/*
- * cc.EaseInOut action with a rate.
- * Slow to fast then to slow.
- * @class EaseInOut
- * @extends EaseRateAction
- *
- * @deprecated since v3.0 please use action.easing(cc.easeInOut(3.0))
- *
- * @example
- * action.easing(cc.easeInOut(3.0));
- */
-cc.EaseInOut = cc.EaseRateAction.extend({
- update:function (dt) {
- dt *= 2;
- if (dt < 1)
- this._inner.update(0.5 * Math.pow(dt, this._rate));
- else
- this._inner.update(1.0 - 0.5 * Math.pow(2 - dt, this._rate));
- },
-
- clone:function(){
- var action = new cc.EaseInOut();
- action.initWithAction(this._inner.clone(), this._rate);
- return action;
- },
-
- reverse:function () {
- return new cc.EaseInOut(this._inner.reverse(), this._rate);
- }
-});
-
/**
* !#en
* Creates the action easing object with the rate parameter.
@@ -323,43 +102,6 @@ cc.easeInOut = function (rate) {
};
};
-/*
- * cc.Ease Exponential In. Slow to Fast.
- * Reference easeInExpo:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseExponentialIn
- * @extends ActionEase
- *
- * @deprecated since v3.0 please action.easing(cc.easeExponentialIn())
- *
- * @example
- * action.easing(cc.easeExponentialIn());
- */
-cc.EaseExponentialIn = cc.ActionEase.extend({
- update:function (dt) {
- this._inner.update(dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1)));
- },
-
- reverse:function () {
- return new cc.EaseExponentialOut(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseExponentialIn();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeExponentialInObj = {
- easing: function(dt){
- return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1));
- },
- reverse: function(){
- return cc._easeExponentialOutObj;
- }
-};
-
/**
* !#en
* Creates the action easing object with the rate parameter.
@@ -374,46 +116,17 @@ cc._easeExponentialInObj = {
* @example
* action.easing(cc.easeExponentialIn());
*/
-cc.easeExponentialIn = function(){
- return cc._easeExponentialInObj;
-};
-
-/*
- * Ease Exponential Out.
- * Reference easeOutExpo:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseExponentialOut
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeExponentialOut())
- *
- * @example
- * action.easing(cc.easeExponentialOut());
- */
-cc.EaseExponentialOut = cc.ActionEase.extend({
- update:function (dt) {
- this._inner.update(dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1));
- },
-
- reverse:function () {
- return new cc.EaseExponentialIn(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseExponentialOut();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeExponentialOutObj = {
+var _easeExponentialInObj = {
easing: function(dt){
- return dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1);
+ return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1));
},
reverse: function(){
- return cc._easeExponentialInObj;
+ return _easeExponentialOutObj;
}
};
+cc.easeExponentialIn = function(){
+ return _easeExponentialInObj;
+};
/**
* !#en
@@ -429,61 +142,17 @@ cc._easeExponentialOutObj = {
* @example
* action.easing(cc.easeExponentialOut());
*/
-cc.easeExponentialOut = function(){
- return cc._easeExponentialOutObj;
-};
-
-/*
- * Ease Exponential InOut.
- * Reference easeInOutExpo:
- * http://www.zhihu.com/question/21981571/answer/19925418
- *
- * @class EaseExponentialInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeExponentialInOut)
- *
- * @example
- * action.easing(cc.easeExponentialInOut());
- */
-cc.EaseExponentialInOut = cc.ActionEase.extend({
- update:function (dt) {
- if( dt !== 1 && dt !== 0) {
- dt *= 2;
- if (dt < 1)
- dt = 0.5 * Math.pow(2, 10 * (dt - 1));
- else
- dt = 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2);
- }
- this._inner.update(dt);
- },
-
- reverse:function () {
- return new cc.EaseExponentialInOut(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseExponentialInOut();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeExponentialInOutObj = {
+var _easeExponentialOutObj = {
easing: function(dt){
- if( dt !== 1 && dt !== 0) {
- dt *= 2;
- if (dt < 1)
- return 0.5 * Math.pow(2, 10 * (dt - 1));
- else
- return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2);
- }
- return dt;
+ return dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1);
},
reverse: function(){
- return cc._easeExponentialInOutObj;
+ return _easeExponentialInObj;
}
};
+cc.easeExponentialOut = function(){
+ return _easeExponentialOutObj;
+};
/**
* !#en
@@ -499,47 +168,25 @@ cc._easeExponentialInOutObj = {
* @example
* action.easing(cc.easeExponentialInOut());
*/
-cc.easeExponentialInOut = function(){
- return cc._easeExponentialInOutObj;
-};
-
-/*
- * Ease Sine In.
- * Reference easeInSine:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseSineIn
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeSineIn())
- *
- * @example
- * action.easing(cc.easeSineIn());
- */
-cc.EaseSineIn = cc.ActionEase.extend({
- update:function (dt) {
- dt = dt===0 || dt===1 ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1;
- this._inner.update(dt);
- },
-
- reverse:function () {
- return new cc.EaseSineOut(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseSineIn();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeSineInObj = {
+var _easeExponentialInOutObj = {
easing: function(dt){
- return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1;
+ if( dt !== 1 && dt !== 0) {
+ dt *= 2;
+ if (dt < 1)
+ return 0.5 * Math.pow(2, 10 * (dt - 1));
+ else
+ return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2);
+ }
+ return dt;
},
reverse: function(){
- return cc._easeSineOutObj;
+ return _easeExponentialInOutObj;
}
};
+cc.easeExponentialInOut = function(){
+ return _easeExponentialInOutObj;
+};
+
/**
* !#en
* Creates an EaseSineIn action.
@@ -554,47 +201,17 @@ cc._easeSineInObj = {
* @example
* action.easing(cc.easeSineIn());
*/
-cc.easeSineIn = function(){
- return cc._easeSineInObj;
-};
-
-/*
- * Ease Sine Out.
- * Reference easeOutSine:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseSineOut
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeSineOut())
- *
- * @example
- * action.easing(cc.easeSineOut());
- */
-cc.EaseSineOut = cc.ActionEase.extend({
- update:function (dt) {
- dt = dt===0 || dt===1 ? dt : Math.sin(dt * Math.PI / 2);
- this._inner.update(dt);
- },
-
- reverse:function () {
- return new cc.EaseSineIn(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseSineOut();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeSineOutObj = {
+var _easeSineInObj = {
easing: function(dt){
- return (dt===0 || dt===1) ? dt : Math.sin(dt * Math.PI / 2);
+ return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1;
},
reverse: function(){
- return cc._easeSineInObj;
+ return _easeSineOutObj;
}
};
+cc.easeSineIn = function(){
+ return _easeSineInObj;
+};
/**
* !#en
@@ -610,47 +227,17 @@ cc._easeSineOutObj = {
* @example
* action.easing(cc.easeSineOut());
*/
-cc.easeSineOut = function(){
- return cc._easeSineOutObj;
-};
-
-/*
- * Ease Sine InOut.
- * Reference easeInOutSine:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class cc.EaseSineInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeSineInOut())
- *
- * @example
- * action.easing(cc.easeSineInOut());
- */
-cc.EaseSineInOut = cc.ActionEase.extend({
- update:function (dt) {
- dt = dt===0 || dt===1 ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1);
- this._inner.update(dt);
- },
-
- clone:function(){
- var action = new cc.EaseSineInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse:function () {
- return new cc.EaseSineInOut(this._inner.reverse());
- }
-});
-
-cc._easeSineInOutObj = {
+var _easeSineOutObj = {
easing: function(dt){
- return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1);
+ return (dt===0 || dt===1) ? dt : Math.sin(dt * Math.PI / 2);
},
reverse: function(){
- return cc._easeSineInOutObj;
+ return _easeSineInObj;
}
};
+cc.easeSineOut = function(){
+ return _easeSineOutObj;
+};
/**
* !#en
@@ -666,121 +253,22 @@ cc._easeSineInOutObj = {
* @example
* action.easing(cc.easeSineInOut());
*/
-cc.easeSineInOut = function(){
- return cc._easeSineInOutObj;
-};
-
-/**
- * !#en Ease Elastic abstract class.
- * !#zh 弹性缓动动作基类。
- * @class EaseElastic
- * @extends ActionEase
- * @param {ActionInterval} action
- * @param {Number} period
- */
-cc.EaseElastic = cc.ActionEase.extend({
- _period: 0.3,
-
- ctor:function(action, period){
- cc.ActionEase.prototype.ctor.call(this);
-
- action && this.initWithAction(action, period);
+var _easeSineInOutObj = {
+ easing: function(dt){
+ return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1);
},
-
- /**
- * get period of the wave in radians. default is 0.3
- * @return {Number}
- */
- getPeriod:function () {
- return this._period;
- },
-
- /**
- * set period of the wave in radians.
- * @param {Number} period
- */
- setPeriod:function (period) {
- this._period = period;
- },
-
- /**
- * Initializes the action with the inner action and the period in radians (default is 0.3)
- * @param {ActionInterval} action
- * @param {Number} [period=0.3]
- * @return {Boolean}
- */
- initWithAction:function (action, period) {
- cc.ActionEase.prototype.initWithAction.call(this, action);
- this._period = (period == null) ? 0.3 : period;
- return true;
- },
-
- reverse:function () {
- cc.logID(1009);
- return null;
- },
-
- clone:function(){
- var action = new cc.EaseElastic();
- action.initWithAction(this._inner.clone(), this._period);
- return action;
+ reverse: function(){
+ return _easeSineInOutObj;
}
-});
+};
+cc.easeSineInOut = function(){
+ return _easeSineInOutObj;
+};
/**
* @module cc
*/
-/*
- * Ease Elastic In action.
- * Reference easeInElastic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseElasticIn
- * @extends EaseElastic
- *
- * @deprecated since v3.0 please use action.easing(cc.easeElasticIn())
- *
- * @example
- * action.easing(cc.easeElasticIn(period));
- */
-cc.EaseElasticIn = cc.EaseElastic.extend({
- update:function (dt) {
- var newT = 0;
- if (dt === 0 || dt === 1) {
- newT = dt;
- } else {
- var s = this._period / 4;
- dt = dt - 1;
- newT = -Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period);
- }
- this._inner.update(newT);
- },
-
- reverse:function () {
- return new cc.EaseElasticOut(this._inner.reverse(), this._period);
- },
-
- clone:function(){
- var action = new cc.EaseElasticIn();
- action.initWithAction(this._inner.clone(), this._period);
- return action;
- }
-});
-
-//default ease elastic in object (period = 0.3)
-cc._easeElasticInObj = {
- easing:function(dt){
- if (dt === 0 || dt === 1)
- return dt;
- dt = dt - 1;
- return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3);
- },
- reverse:function(){
- return cc._easeElasticOutObj;
- }
-};
-
/**
* !#en
* Creates the action easing obejct with the period in radians (default is 0.3).
@@ -797,6 +285,18 @@ cc._easeElasticInObj = {
* // example
* action.easing(cc.easeElasticIn(3.0));
*/
+//default ease elastic in object (period = 0.3)
+var _easeElasticInObj = {
+ easing:function(dt){
+ if (dt === 0 || dt === 1)
+ return dt;
+ dt = dt - 1;
+ return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3);
+ },
+ reverse:function(){
+ return _easeElasticOutObj;
+ }
+ };
cc.easeElasticIn = function (period) {
if(period && period !== 0.3){
return {
@@ -812,55 +312,9 @@ cc.easeElasticIn = function (period) {
}
};
}
- return cc._easeElasticInObj;
+ return _easeElasticInObj;
};
-/*
- * Ease Elastic Out action.
- * Reference easeOutElastic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseElasticOut
- * @extends EaseElastic
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeElasticOut(period))
- *
- * @example
- * action.easing(cc.easeElasticOut(period));
- */
-cc.EaseElasticOut = cc.EaseElastic.extend({
- update:function (dt) {
- var newT = 0;
- if (dt === 0 || dt === 1) {
- newT = dt;
- } else {
- var s = this._period / 4;
- newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period) + 1;
- }
-
- this._inner.update(newT);
- },
-
- reverse:function () {
- return new cc.EaseElasticIn(this._inner.reverse(), this._period);
- },
-
- clone:function(){
- var action = new cc.EaseElasticOut();
- action.initWithAction(this._inner.clone(), this._period);
- return action;
- }
-});
-
-//default ease elastic out object (period = 0.3)
-cc._easeElasticOutObj = {
- easing: function (dt) {
- return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1;
- },
- reverse:function(){
- return cc._easeElasticInObj;
- }
-};
/**
* !#en
* Creates the action easing object with the period in radians (default is 0.3).
@@ -877,6 +331,15 @@ cc._easeElasticOutObj = {
* // example
* action.easing(cc.easeElasticOut(3.0));
*/
+//default ease elastic out object (period = 0.3)
+var _easeElasticOutObj = {
+ easing: function (dt) {
+ return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1;
+ },
+ reverse:function(){
+ return _easeElasticInObj;
+ }
+};
cc.easeElasticOut = function (period) {
if(period && period !== 0.3){
return {
@@ -889,54 +352,9 @@ cc.easeElasticOut = function (period) {
}
};
}
- return cc._easeElasticOutObj;
+ return _easeElasticOutObj;
};
-/*
- * Ease Elastic InOut action.
- * Reference easeInOutElastic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseElasticInOut
- * @extends EaseElastic
- *
- * @deprecated since v3.0 please use action.easing(cc.easeElasticInOut())
- *
- * @example
- * action.easing(cc.easeElasticInOut(period));
- */
-cc.EaseElasticInOut = cc.EaseElastic.extend({
- update:function (dt) {
- var newT = 0;
- var locPeriod = this._period;
- if (dt === 0 || dt === 1) {
- newT = dt;
- } else {
- dt = dt * 2;
- if (!locPeriod)
- locPeriod = this._period = 0.3 * 1.5;
-
- var s = locPeriod / 4;
- dt = dt - 1;
- if (dt < 0)
- newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod);
- else
- newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1;
- }
- this._inner.update(newT);
- },
-
- reverse:function () {
- return new cc.EaseElasticInOut(this._inner.reverse(), this._period);
- },
-
- clone:function(){
- var action = new cc.EaseElasticInOut();
- action.initWithAction(this._inner.clone(), this._period);
- return action;
- }
-});
-
/**
* !#en
* Creates the action easing object with the period in radians (default is 0.3).
@@ -981,77 +399,11 @@ cc.easeElasticInOut = function (period) {
};
};
-/**
- * !#en cc.EaseBounce abstract class.
- * !#zh 反弹缓动动作基类。
- * @class EaseBounce
- * @extends ActionEase
- */
-cc.EaseBounce = cc.ActionEase.extend({
- /**
- * @param {Number} time1
- * @return {Number}
- */
- bounceTime:function (time1) {
- if (time1 < 1 / 2.75) {
- return 7.5625 * time1 * time1;
- } else if (time1 < 2 / 2.75) {
- time1 -= 1.5 / 2.75;
- return 7.5625 * time1 * time1 + 0.75;
- } else if (time1 < 2.5 / 2.75) {
- time1 -= 2.25 / 2.75;
- return 7.5625 * time1 * time1 + 0.9375;
- }
-
- time1 -= 2.625 / 2.75;
- return 7.5625 * time1 * time1 + 0.984375;
- },
-
- clone:function(){
- var action = new cc.EaseBounce();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse:function () {
- return new cc.EaseBounce(this._inner.reverse());
- }
-});
-
/**
* @module cc
*/
-/*
- * cc.EaseBounceIn action.
- * Eased bounce effect at the beginning.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBounceIn
- * @extends EaseBounce
- *
- * @deprecated since v3.0 please use action.easing(cc.easeBounceIn())
- *
- * @example
- * action.easing(cc.easeBounceIn());
- */
-cc.EaseBounceIn = cc.EaseBounce.extend({
- update:function (dt) {
- var newT = 1 - this.bounceTime(1 - dt);
- this._inner.update(newT);
- },
-
- reverse:function () {
- return new cc.EaseBounceOut(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseBounceIn();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._bounceTime = function (time1) {
+function _bounceTime (time1) {
if (time1 < 1 / 2.75) {
return 7.5625 * time1 * time1;
} else if (time1 < 2 / 2.75) {
@@ -1066,12 +418,12 @@ cc._bounceTime = function (time1) {
return 7.5625 * time1 * time1 + 0.984375;
};
-cc._easeBounceInObj = {
+var _easeBounceInObj = {
easing: function(dt){
- return 1 - cc._bounceTime(1 - dt);
+ return 1 - _bounceTime(1 - dt);
},
reverse: function(){
- return cc._easeBounceOutObj;
+ return _easeBounceOutObj;
}
};
@@ -1089,45 +441,7 @@ cc._easeBounceInObj = {
* action.easing(cc.easeBounceIn());
*/
cc.easeBounceIn = function(){
- return cc._easeBounceInObj;
-};
-
-/*
- * cc.EaseBounceOut action.
- * Eased bounce effect at the ending.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBounceOut
- * @extends EaseBounce
- *
- * @deprecated since v3.0 please use action.easing(cc.easeBounceOut())
- *
- * @example
- * action.easing(cc.easeBounceOut());
- */
-cc.EaseBounceOut = cc.EaseBounce.extend({
- update:function (dt) {
- var newT = this.bounceTime(dt);
- this._inner.update(newT);
- },
-
- reverse:function () {
- return new cc.EaseBounceIn(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseBounceOut();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeBounceOutObj = {
- easing: function(dt){
- return cc._bounceTime(dt);
- },
- reverse:function () {
- return cc._easeBounceInObj;
- }
+ return _easeBounceInObj;
};
/**
@@ -1143,60 +457,17 @@ cc._easeBounceOutObj = {
* // example
* action.easing(cc.easeBounceOut());
*/
-cc.easeBounceOut = function(){
- return cc._easeBounceOutObj;
-};
-
-/*
- * cc.EaseBounceInOut action.
- * Eased bounce effect at the begining and ending.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBounceInOut
- * @extends EaseBounce
- *
- * @deprecated since v3.0
Please use acton.easing(cc.easeBounceInOut())
- *
- * @example
- * action.easing(cc.easeBounceInOut());
- */
-cc.EaseBounceInOut = cc.EaseBounce.extend({
- update:function (dt) {
- var newT = 0;
- if (dt < 0.5) {
- dt = dt * 2;
- newT = (1 - this.bounceTime(1 - dt)) * 0.5;
- } else {
- newT = this.bounceTime(dt * 2 - 1) * 0.5 + 0.5;
- }
- this._inner.update(newT);
+var _easeBounceOutObj = {
+ easing: function(dt){
+ return _bounceTime(dt);
},
-
- clone:function(){
- var action = new cc.EaseBounceInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
reverse:function () {
- return new cc.EaseBounceInOut(this._inner.reverse());
- }
-});
-
-cc._easeBounceInOutObj = {
- easing: function (time1) {
- var newT;
- if (time1 < 0.5) {
- time1 = time1 * 2;
- newT = (1 - cc._bounceTime(1 - time1)) * 0.5;
- } else {
- newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5;
- }
- return newT;
- },
- reverse: function(){
- return cc._easeBounceInOutObj;
+ return _easeBounceInObj;
}
};
+cc.easeBounceOut = function(){
+ return _easeBounceOutObj;
+};
/**
* !#en
@@ -1211,49 +482,24 @@ cc._easeBounceInOutObj = {
* // example
* action.easing(cc.easeBounceInOut());
*/
-cc.easeBounceInOut = function(){
- return cc._easeBounceInOutObj;
-};
-
-/*
- * cc.EaseBackIn action.
- * In the opposite direction to move slowly, and then accelerated to the right direction.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBackIn
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeBackIn())
- *
- * @example
- * action.easing(cc.easeBackIn());
- */
-cc.EaseBackIn = cc.ActionEase.extend({
- update:function (dt) {
- var overshoot = 1.70158;
- dt = dt===0 || dt===1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot);
- this._inner.update(dt);
- },
-
- reverse:function () {
- return new cc.EaseBackOut(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseBackIn();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeBackInObj = {
+var _easeBounceInOutObj = {
easing: function (time1) {
- var overshoot = 1.70158;
- return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot);
+ var newT;
+ if (time1 < 0.5) {
+ time1 = time1 * 2;
+ newT = (1 - _bounceTime(1 - time1)) * 0.5;
+ } else {
+ newT = _bounceTime(time1 * 2 - 1) * 0.5 + 0.5;
+ }
+ return newT;
},
reverse: function(){
- return cc._easeBackOutObj;
+ return _easeBounceInOutObj;
}
};
+cc.easeBounceInOut = function(){
+ return _easeBounceInOutObj;
+};
/**
* !#en
@@ -1268,50 +514,18 @@ cc._easeBackInObj = {
* // example
* action.easing(cc.easeBackIn());
*/
-cc.easeBackIn = function(){
- return cc._easeBackInObj;
-};
-
-/*
- * cc.EaseBackOut action.
- * Fast moving more than the finish, and then slowly back to the finish.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBackOut
- * @extends ActionEase
- *
- * @deprecated since v3.0 please use action.easing(cc.easeBackOut());
- *
- * @example
- * action.easing(cc.easeBackOut());
- */
-cc.EaseBackOut = cc.ActionEase.extend({
- update:function (dt) {
- var overshoot = 1.70158;
- dt = dt - 1;
- this._inner.update(dt * dt * ((overshoot + 1) * dt + overshoot) + 1);
- },
-
- reverse:function () {
- return new cc.EaseBackIn(this._inner.reverse());
- },
-
- clone:function(){
- var action = new cc.EaseBackOut();
- action.initWithAction(this._inner.clone());
- return action;
- }
-});
-
-cc._easeBackOutObj = {
+var _easeBackInObj = {
easing: function (time1) {
var overshoot = 1.70158;
- time1 = time1 - 1;
- return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1;
+ return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot);
},
reverse: function(){
- return cc._easeBackInObj;
+ return _easeBackOutObj;
}
};
+cc.easeBackIn = function(){
+ return _easeBackInObj;
+};
/**
* !#en
@@ -1326,60 +540,19 @@ cc._easeBackOutObj = {
* // example
* action.easing(cc.easeBackOut());
*/
-cc.easeBackOut = function(){
- return cc._easeBackOutObj;
-};
-
-/*
- * cc.EaseBackInOut action.
- * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
- * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
- * @class EaseBackInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeBackInOut())
- *
- * @example
- * action.easing(cc.easeBackInOut());
- */
-cc.EaseBackInOut = cc.ActionEase.extend({
- update:function (dt) {
- var overshoot = 1.70158 * 1.525;
- dt = dt * 2;
- if (dt < 1) {
- this._inner.update((dt * dt * ((overshoot + 1) * dt - overshoot)) / 2);
- } else {
- dt = dt - 2;
- this._inner.update((dt * dt * ((overshoot + 1) * dt + overshoot)) / 2 + 1);
- }
- },
-
- clone:function(){
- var action = new cc.EaseBackInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse:function () {
- return new cc.EaseBackInOut(this._inner.reverse());
- }
-});
-
-cc._easeBackInOutObj = {
+var _easeBackOutObj = {
easing: function (time1) {
- var overshoot = 1.70158 * 1.525;
- time1 = time1 * 2;
- if (time1 < 1) {
- return (time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2;
- } else {
- time1 = time1 - 2;
- return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1;
- }
+ var overshoot = 1.70158;
+ time1 = time1 - 1;
+ return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1;
},
reverse: function(){
- return cc._easeBackInOutObj;
+ return _easeBackInObj;
}
};
+cc.easeBackOut = function(){
+ return _easeBackOutObj;
+};
/**
* !#en
@@ -1393,75 +566,24 @@ cc._easeBackInOutObj = {
* // example
* action.easing(cc.easeBackInOut());
*/
-cc.easeBackInOut = function(){
- return cc._easeBackInOutObj;
-};
-
-/*
- * cc.EaseBezierAction action.
- * Manually set a 4 order Bessel curve.
- * According to the set point, calculate the trajectory.
- * @class EaseBezierAction
- * @extends ActionEase
- * @param {Action} action
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeBezierAction())
- *
- * @example
- * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
- */
-cc.EaseBezierAction = cc.ActionEase.extend({
-
- _p0: null,
- _p1: null,
- _p2: null,
- _p3: null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Initialization requires the application of Bessel curve of action.
- * @param {Action} action
- */
- ctor: function(action){
- cc.ActionEase.prototype.ctor.call(this, action);
+var _easeBackInOutObj = {
+ easing: function (time1) {
+ var overshoot = 1.70158 * 1.525;
+ time1 = time1 * 2;
+ if (time1 < 1) {
+ return (time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2;
+ } else {
+ time1 = time1 - 2;
+ return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1;
+ }
},
-
- _updateTime: function(a, b, c, d, t){
- return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d );
- },
-
- update: function(dt){
- var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, dt);
- this._inner.update(t);
- },
-
- clone: function(){
- var action = new cc.EaseBezierAction();
- action.initWithAction(this._inner.clone());
- action.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
- return action;
- },
-
reverse: function(){
- var action = new cc.EaseBezierAction(this._inner.reverse());
- action.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
- return action;
- },
-
- /**
- * Set of 4 reference point
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- setBezierParamer: function(p0, p1, p2, p3){
- this._p0 = p0 || 0;
- this._p1 = p1 || 0;
- this._p2 = p2 || 0;
- this._p3 = p3 || 0;
+ return _easeBackInOutObj;
}
-});
+};
+cc.easeBackInOut = function(){
+ return _easeBackInOutObj;
+};
/**
* !#en
@@ -1481,58 +603,17 @@ cc.EaseBezierAction = cc.ActionEase.extend({
* // example
* action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
*/
-cc.easeBezierAction = function(p0, p1, p2, p3){
+cc.easeBezierAction = function(a, b, c, d){
return {
- easing: function(time){
- return cc.EaseBezierAction.prototype._updateTime(p0, p1, p2, p3, time);
+ easing: function(t){
+ return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d);
},
reverse: function(){
- return cc.easeBezierAction(p3, p2, p1, p0);
+ return cc.easeBezierAction(d, c, b, a);
}
};
};
-/*
- * cc.EaseQuadraticActionIn action.
- * Reference easeInQuad:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuadraticActionIn
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuadraticAction())
- *
- * @example
- * action.easing(cc.easeQuadraticActionIn());
- */
-cc.EaseQuadraticActionIn = cc.ActionEase.extend({
-
- _updateTime: function(time){
- return Math.pow(time, 2);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuadraticActionIn();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuadraticActionIn(this._inner.reverse());
- }
-
-});
-
-cc._easeQuadraticActionIn = {
- easing: cc.EaseQuadraticActionIn.prototype._updateTime,
- reverse: function(){
- return cc._easeQuadraticActionIn;
- }
-};
-
/**
* !#en
* Creates the action easing object.
@@ -1548,49 +629,18 @@ cc._easeQuadraticActionIn = {
* //example
* action.easing(cc.easeQuadraticActionIn());
*/
+var _easeQuadraticActionIn = {
+ easing: function(time){
+ return Math.pow(time, 2);
+ },
+ reverse: function(){
+ return _easeQuadraticActionIn;
+ }
+};
cc.easeQuadraticActionIn = function(){
- return cc._easeQuadraticActionIn;
+ return _easeQuadraticActionIn;
};
-/*
- * cc.EaseQuadraticActionIn action.
- * Reference easeOutQuad:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuadraticActionOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuadraticActionOut())
- *
- * @example
- * action.easing(cc.easeQuadraticActionOut());
- */
-cc.EaseQuadraticActionOut = cc.ActionEase.extend({
-
- _updateTime: function(time){
- return -time*(time-2);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuadraticActionOut();
- action.initWithAction();
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuadraticActionOut(this._inner.reverse());
- }
-});
-
-cc._easeQuadraticActionOut = {
- easing: cc.EaseQuadraticActionOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuadraticActionOut;
- }
-};
/**
* !#en
* Creates the action easing object.
@@ -1606,55 +656,16 @@ cc._easeQuadraticActionOut = {
* //example
* action.easing(cc.easeQuadraticActionOut());
*/
-cc.easeQuadraticActionOut = function(){
- return cc._easeQuadraticActionOut;
+var _easeQuadraticActionOut = {
+ easing: function(time){
+ return -time*(time-2);
+ },
+ reverse: function(){
+ return _easeQuadraticActionOut;
+ }
};
-
-/*
- * cc.EaseQuadraticActionInOut action.
- * Reference easeInOutQuad:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuadraticActionInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuadraticActionInOut())
- *
- * @example
- * action.easing(cc.easeQuadraticActionInOut());
- */
-cc.EaseQuadraticActionInOut = cc.ActionEase.extend({
- _updateTime: function(time){
- var resultTime = time;
- time *= 2;
- if(time < 1){
- resultTime = time * time * 0.5;
- }else{
- --time;
- resultTime = -0.5 * ( time * ( time - 2 ) - 1)
- }
- return resultTime;
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuadraticActionInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuadraticActionInOut(this._inner.reverse());
- }
-});
-
-cc._easeQuadraticActionInOut = {
- easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuadraticActionInOut;
- }
+cc.easeQuadraticActionOut = function(){
+ return _easeQuadraticActionOut;
};
/**
@@ -1672,48 +683,26 @@ cc._easeQuadraticActionInOut = {
* //example
* action.easing(cc.easeQuadraticActionInOut());
*/
+var _easeQuadraticActionInOut = {
+ easing: function(time){
+ var resultTime = time;
+ time *= 2;
+ if(time < 1){
+ resultTime = time * time * 0.5;
+ }else{
+ --time;
+ resultTime = -0.5 * ( time * ( time - 2 ) - 1)
+ }
+ return resultTime;
+ },
+ reverse: function(){
+ return _easeQuadraticActionInOut;
+ }
+};
cc.easeQuadraticActionInOut = function(){
- return cc._easeQuadraticActionInOut;
+ return _easeQuadraticActionInOut;
};
-/*
- * cc.EaseQuarticActionIn action.
- * Reference easeInQuart:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuarticActionIn
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuarticActionIn());
- *
- * @example
- * action.easing(cc.easeQuarticActionIn());
- */
-cc.EaseQuarticActionIn = cc.ActionEase.extend({
- _updateTime: function(time){
- return time * time * time * time;
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuarticActionIn();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuarticActionIn(this._inner.reverse());
- }
-});
-
-cc._easeQuarticActionIn = {
- easing: cc.EaseQuarticActionIn.prototype._updateTime,
- reverse: function(){
- return cc._easeQuarticActionIn;
- }
-};
/**
* !#en
* Creates the action easing object.
@@ -1729,48 +718,16 @@ cc._easeQuarticActionIn = {
* //example
* action.easing(cc.easeQuarticActionIn());
*/
-cc.easeQuarticActionIn = function(){
- return cc._easeQuarticActionIn;
+var _easeQuarticActionIn = {
+ easing: function(time){
+ return time * time * time * time;
+ },
+ reverse: function(){
+ return _easeQuarticActionIn;
+ }
};
-
-/*
- * cc.EaseQuarticActionOut action.
- * Reference easeOutQuart:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuarticActionOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.QuarticActionOut());
- *
- * @example
- * action.easing(cc.EaseQuarticActionOut());
- */
-cc.EaseQuarticActionOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time -= 1;
- return -(time * time * time * time - 1);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuarticActionOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuarticActionOut(this._inner.reverse());
- }
-});
-
-cc._easeQuarticActionOut = {
- easing: cc.EaseQuarticActionOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuarticActionOut;
- }
+cc.easeQuarticActionIn = function(){
+ return _easeQuarticActionIn;
};
/**
@@ -1788,52 +745,19 @@ cc._easeQuarticActionOut = {
* //example
* action.easing(cc.QuarticActionOut());
*/
+var _easeQuarticActionOut = {
+ easing: function(time){
+ time -= 1;
+ return -(time * time * time * time - 1);
+ },
+ reverse: function(){
+ return _easeQuarticActionOut;
+ }
+};
cc.easeQuarticActionOut = function(){
- return cc._easeQuarticActionOut;
+ return _easeQuarticActionOut;
};
-/*
- * cc.EaseQuarticActionInOut action.
- * Reference easeInOutQuart:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuarticActionInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuarticActionInOut());
- *
- * @example
- * action.easing(cc.easeQuarticActionInOut());
- */
-cc.EaseQuarticActionInOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time = time*2;
- if (time < 1)
- return 0.5 * time * time * time * time;
- time -= 2;
- return -0.5 * (time * time * time * time - 2);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuarticActionInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuarticActionInOut(this._inner.reverse());
- }
-});
-
-cc._easeQuarticActionInOut = {
- easing: cc.EaseQuarticActionInOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuarticActionInOut;
- }
-};
/**
* !#en
* Creates the action easing object.
@@ -1846,47 +770,20 @@ cc._easeQuarticActionInOut = {
* @method easeQuarticActionInOut
* @returns {Object}
*/
-cc.easeQuarticActionInOut = function(){
- return cc._easeQuarticActionInOut;
+var _easeQuarticActionInOut = {
+ easing: function(time){
+ time = time*2;
+ if (time < 1)
+ return 0.5 * time * time * time * time;
+ time -= 2;
+ return -0.5 * (time * time * time * time - 2);
+ },
+ reverse: function(){
+ return _easeQuarticActionInOut;
+ }
};
-
-/*
- * cc.EaseQuinticActionIn action.
- * Reference easeInQuint:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuinticActionIn
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuinticActionIn());
- *
- * @example
- * action.easing(cc.easeQuinticActionIn());
- */
-cc.EaseQuinticActionIn = cc.ActionEase.extend({
- _updateTime: function(time){
- return time * time * time * time * time;
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuinticActionIn();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuinticActionIn(this._inner.reverse());
- }
-});
-
-cc._easeQuinticActionIn = {
- easing: cc.EaseQuinticActionIn.prototype._updateTime,
- reverse: function(){
- return cc._easeQuinticActionIn;
- }
+cc.easeQuarticActionInOut = function(){
+ return _easeQuarticActionInOut;
};
/**
@@ -1904,48 +801,16 @@ cc._easeQuinticActionIn = {
* //example
* action.easing(cc.easeQuinticActionIn());
*/
-cc.easeQuinticActionIn = function(){
- return cc._easeQuinticActionIn;
+var _easeQuinticActionIn = {
+ easing: function(time){
+ return time * time * time * time * time;
+ },
+ reverse: function(){
+ return _easeQuinticActionIn;
+ }
};
-
-/*
- * cc.EaseQuinticActionOut action.
- * Reference easeQuint:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuinticActionOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuadraticActionOut());
- *
- * @example
- * action.easing(cc.easeQuadraticActionOut());
- */
-cc.EaseQuinticActionOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time -=1;
- return (time * time * time * time * time + 1);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuinticActionOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuinticActionOut(this._inner.reverse());
- }
-});
-
-cc._easeQuinticActionOut = {
- easing: cc.EaseQuinticActionOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuinticActionOut;
- }
+cc.easeQuinticActionIn = function(){
+ return _easeQuinticActionIn;
};
/**
@@ -1963,51 +828,17 @@ cc._easeQuinticActionOut = {
* //example
* action.easing(cc.easeQuadraticActionOut());
*/
-cc.easeQuinticActionOut = function(){
- return cc._easeQuinticActionOut;
+var _easeQuinticActionOut = {
+ easing: function(time){
+ time -=1;
+ return (time * time * time * time * time + 1);
+ },
+ reverse: function(){
+ return _easeQuinticActionOut;
+ }
};
-
-/*
- * cc.EaseQuinticActionInOut action.
- * Reference easeInOutQuint:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseQuinticActionInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeQuinticActionInOut());
- *
- * @example
- * action.easing(cc.easeQuinticActionInOut());
- */
-cc.EaseQuinticActionInOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time = time*2;
- if (time < 1)
- return 0.5 * time * time * time * time * time;
- time -= 2;
- return 0.5 * (time * time * time * time * time + 2);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseQuinticActionInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseQuinticActionInOut(this._inner.reverse());
- }
-});
-
-cc._easeQuinticActionInOut = {
- easing: cc.EaseQuinticActionInOut.prototype._updateTime,
- reverse: function(){
- return cc._easeQuinticActionInOut;
- }
+cc.easeQuinticActionOut = function(){
+ return _easeQuinticActionOut;
};
/**
@@ -2025,47 +856,20 @@ cc._easeQuinticActionInOut = {
* //example
* action.easing(cc.easeQuinticActionInOut());
*/
-cc.easeQuinticActionInOut = function(){
- return cc._easeQuinticActionInOut;
+var _easeQuinticActionInOut = {
+ easing: function(time){
+ time = time*2;
+ if (time < 1)
+ return 0.5 * time * time * time * time * time;
+ time -= 2;
+ return 0.5 * (time * time * time * time * time + 2);
+ },
+ reverse: function(){
+ return _easeQuinticActionInOut;
+ }
};
-
-/*
- * cc.EaseCircleActionIn action.
- * Reference easeInCirc:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCircleActionIn
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeCircleActionIn());
- *
- * @example
- * action.easing(cc.easeCircleActionIn());
- */
-cc.EaseCircleActionIn = cc.ActionEase.extend({
- _updateTime: function(time){
- return -1 * (Math.sqrt(1 - time * time) - 1);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCircleActionIn();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCircleActionIn(this._inner.reverse());
- }
-});
-
-cc._easeCircleActionIn = {
- easing: cc.EaseCircleActionIn.prototype._updateTime,
- reverse: function(){
- return cc._easeCircleActionIn;
- }
+cc.easeQuinticActionInOut = function(){
+ return _easeQuinticActionInOut;
};
/**
@@ -2083,48 +887,16 @@ cc._easeCircleActionIn = {
* //example
* action.easing(cc.easeCircleActionIn());
*/
-cc.easeCircleActionIn = function(){
- return cc._easeCircleActionIn;
+var _easeCircleActionIn = {
+ easing: function(time){
+ return -1 * (Math.sqrt(1 - time * time) - 1);
+ },
+ reverse: function(){
+ return _easeCircleActionIn;
+ }
};
-
-/*
- * cc.EaseCircleActionOut action.
- * Reference easeOutCirc:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCircleActionOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeCircleActionOut());
- *
- * @example
- * action.easing(cc.easeCircleActionOut());
- */
-cc.EaseCircleActionOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time = time - 1;
- return Math.sqrt(1 - time * time);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCircleActionOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCircleActionOut(this._inner.reverse());
- }
-});
-
-cc._easeCircleActionOut = {
- easing: cc.EaseCircleActionOut.prototype._updateTime,
- reverse: function(){
- return cc._easeCircleActionOut;
- }
+cc.easeCircleActionIn = function(){
+ return _easeCircleActionIn;
};
/**
@@ -2142,51 +914,17 @@ cc._easeCircleActionOut = {
* //example
* actioneasing(cc.easeCircleActionOut());
*/
-cc.easeCircleActionOut = function(){
- return cc._easeCircleActionOut;
+var _easeCircleActionOut = {
+ easing: function(time){
+ time = time - 1;
+ return Math.sqrt(1 - time * time);
+ },
+ reverse: function(){
+ return _easeCircleActionOut;
+ }
};
-
-/*
- * cc.EaseCircleActionInOut action.
- * Reference easeInOutCirc:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCircleActionInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeCircleActionInOut());
- *
- * @example
- * action.easing(cc.easeCircleActionInOut());
- */
-cc.EaseCircleActionInOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time = time * 2;
- if (time < 1)
- return -0.5 * (Math.sqrt(1 - time * time) - 1);
- time -= 2;
- return 0.5 * (Math.sqrt(1 - time * time) + 1);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCircleActionInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCircleActionInOut(this._inner.reverse());
- }
-});
-
-cc._easeCircleActionInOut = {
- easing: cc.EaseCircleActionInOut.prototype._updateTime,
- reverse: function(){
- return cc._easeCircleActionInOut;
- }
+cc.easeCircleActionOut = function(){
+ return _easeCircleActionOut;
};
/**
@@ -2204,47 +942,20 @@ cc._easeCircleActionInOut = {
* //example
* action.easing(cc.easeCircleActionInOut());
*/
-cc.easeCircleActionInOut = function(){
- return cc._easeCircleActionInOut;
+var _easeCircleActionInOut = {
+ easing: function(time){
+ time = time * 2;
+ if (time < 1)
+ return -0.5 * (Math.sqrt(1 - time * time) - 1);
+ time -= 2;
+ return 0.5 * (Math.sqrt(1 - time * time) + 1);
+ },
+ reverse: function(){
+ return _easeCircleActionInOut;
+ }
};
-
-/*
- * cc.EaseCubicActionIn action.
- * Reference easeInCubic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCubicActionIn
- * @extends ActionEase
- *
- * @deprecated since v3.0
action.easing(cc.easeCubicActionIn());
- *
- * @example
- * action.easing(cc.easeCubicActionIn());
- */
-cc.EaseCubicActionIn = cc.ActionEase.extend({
- _updateTime: function(time){
- return time * time * time;
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCubicActionIn();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCubicActionIn(this._inner.reverse());
- }
-});
-
-cc._easeCubicActionIn = {
- easing: cc.EaseCubicActionIn.prototype._updateTime,
- reverse: function(){
- return cc._easeCubicActionIn;
- }
+cc.easeCircleActionInOut = function(){
+ return _easeCircleActionInOut;
};
/**
@@ -2262,48 +973,16 @@ cc._easeCubicActionIn = {
* //example
* action.easing(cc.easeCubicActionIn());
*/
-cc.easeCubicActionIn = function(){
- return cc._easeCubicActionIn;
+var _easeCubicActionIn = {
+ easing: function(time){
+ return time * time * time;
+ },
+ reverse: function(){
+ return _easeCubicActionIn;
+ }
};
-
-/*
- * cc.EaseCubicActionOut action.
- * Reference easeOutCubic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCubicActionOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeCubicActionOut());
- *
- * @example
- * action.easing(cc.easeCubicActionOut());
- */
-cc.EaseCubicActionOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time -= 1;
- return (time * time * time + 1);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCubicActionOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCubicActionOut(this._inner.reverse());
- }
-});
-
-cc._easeCubicActionOut = {
- easing: cc.EaseCubicActionOut.prototype._updateTime,
- reverse: function(){
- return cc._easeCubicActionOut;
- }
+cc.easeCubicActionIn = function(){
+ return _easeCubicActionIn;
};
/**
@@ -2321,51 +1000,17 @@ cc._easeCubicActionOut = {
* //example
* action.easing(cc.easeCubicActionOut());
*/
-cc.easeCubicActionOut = function(){
- return cc._easeCubicActionOut;
+var _easeCubicActionOut = {
+ easing: function(time){
+ time -= 1;
+ return (time * time * time + 1);
+ },
+ reverse: function(){
+ return _easeCubicActionOut;
+ }
};
-
-/*
- * cc.EaseCubicActionInOut action.
- * Reference easeInOutCubic:
- * http://www.zhihu.com/question/21981571/answer/19925418
- * @class EaseCubicActionInOut
- * @extends ActionEase
- *
- * @deprecated since v3.0
Please use action.easing(cc.easeCubicActionInOut());
- *
- * @example
- * action.easing(cc.easeCubicActionInOut());
- */
-cc.EaseCubicActionInOut = cc.ActionEase.extend({
- _updateTime: function(time){
- time = time*2;
- if (time < 1)
- return 0.5 * time * time * time;
- time -= 2;
- return 0.5 * (time * time * time + 2);
- },
-
- update: function(dt){
- this._inner.update(this._updateTime(dt));
- },
-
- clone: function(){
- var action = new cc.EaseCubicActionInOut();
- action.initWithAction(this._inner.clone());
- return action;
- },
-
- reverse: function(){
- return new cc.EaseCubicActionInOut(this._inner.reverse());
- }
-});
-
-cc._easeCubicActionInOut = {
- easing: cc.EaseCubicActionInOut.prototype._updateTime,
- reverse: function(){
- return cc._easeCubicActionInOut;
- }
+cc.easeCubicActionOut = function(){
+ return _easeCubicActionOut;
};
/**
@@ -2380,7 +1025,19 @@ cc._easeCubicActionInOut = {
* @method easeCubicActionInOut
* @returns {Object}
*/
+var _easeCubicActionInOut = {
+ easing: function(time){
+ time = time*2;
+ if (time < 1)
+ return 0.5 * time * time * time;
+ time -= 2;
+ return 0.5 * (time * time * time + 2);
+ },
+ reverse: function(){
+ return _easeCubicActionInOut;
+ }
+};
cc.easeCubicActionInOut = function(){
- return cc._easeCubicActionInOut;
+ return _easeCubicActionInOut;
};
diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js
index 1727cc34ed..b90b3bb3b6 100644
--- a/cocos2d/actions/CCActionInstant.js
+++ b/cocos2d/actions/CCActionInstant.js
@@ -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.
@@ -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);
},
diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js
index 97d3f71d0e..727d3af0de 100644
--- a/cocos2d/actions/CCActionInterval.js
+++ b/cocos2d/actions/CCActionInterval.js
@@ -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);
-};
-
/*
*
* Overrides the target of an action so that it always runs on the target
@@ -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);
},
diff --git a/cocos2d/actions/CCActionManager.js b/cocos2d/actions/CCActionManager.js
index 09a20992f8..c0db024b13 100644
--- a/cocos2d/actions/CCActionManager.js
+++ b/cocos2d/actions/CCActionManager.js
@@ -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,