Merge branch 'master' into refineSprite

This commit is contained in:
Huabing.Xu
2016-01-13 11:27:09 +08:00
17 changed files with 950 additions and 3388 deletions
+84 -212
View File
@@ -24,6 +24,10 @@
THE SOFTWARE.
****************************************************************************/
/**
* @module actions
*/
/** Default Action tag
* @constant
* @type {Number}
@@ -32,16 +36,12 @@
cc.ACTION_TAG_INVALID = -1;
/**
* Base class for cc.Action objects.
* @class
* Base class cc.Action for action classes.
* @class Action
*
* @extends cc._Class
*
* @property {_ccsg.Node} target - The target will be set with the 'startWithTarget' method. When the 'stop' method is called, target will be set to nil.
* @property {_ccsg.Node} originalTarget - The original target of the action.
* @property {Number} tag - The tag of the action, can be used to find the action.
* @extends _Class
*/
cc.Action = cc._Class.extend(/** @lends cc.Action# */{
cc.Action = cc._Class.extend({
//***********variables*************
originalTarget:null,
target:null,
@@ -49,32 +49,17 @@ cc.Action = cc._Class.extend(/** @lends cc.Action# */{
//**************Public Functions***********
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
*/
ctor:function () {
this.originalTarget = null;
this.target = null;
this.tag = cc.ACTION_TAG_INVALID;
},
/**
* to copy object with deep copy.
*
* @deprecated since v3.0 please use .clone
*
* @return {cc.Action}
*/
copy:function () {
cc.log("copy is deprecated. Please use clone instead.");
return this.clone();
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.Action}
* @method clone
* @return {Action}
*/
clone:function () {
var action = new cc.Action();
@@ -86,54 +71,38 @@ cc.Action = cc._Class.extend(/** @lends cc.Action# */{
/**
* return true if the action has finished.
*
* @method isDone
* @return {Boolean}
*/
isDone:function () {
return true;
},
/**
* called before the action start. It will also set the target.
*
* @param {_ccsg.Node} target
*/
// called before the action start. It will also set the target.
startWithTarget:function (target) {
this.originalTarget = target;
this.target = target;
},
/**
* called after the action has finished. It will set the 'target' to nil. <br />
* IMPORTANT: You should never call "action stop" manually. Instead, use: "target.stopAction(action);"
*/
// called after the action has finished. It will set the 'target' to nil.
stop:function () {
this.target = null;
},
/**
* called every frame with it's delta time. <br />
* DON'T override unless you know what you are doing.
*
* @param {Number} dt
*/
// called every frame with it's delta time. <br />
step:function (dt) {
cc.log("[Action step]. override me");
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
// Called once per frame. Time is the number of seconds of a frame interval.
update:function (dt) {
cc.log("[Action update]. override me");
},
/**
* get the target.
*
* @return {_ccsg.Node}
* @method getTarget
* @return {Node}
*/
getTarget:function () {
return this.target;
@@ -141,8 +110,8 @@ cc.Action = cc._Class.extend(/** @lends cc.Action# */{
/**
* The action will modify the target properties.
*
* @param {_ccsg.Node} target
* @method setTarget
* @param {Node} target
*/
setTarget:function (target) {
this.target = target;
@@ -150,26 +119,23 @@ cc.Action = cc._Class.extend(/** @lends cc.Action# */{
/**
* get the original target.
*
* @return {_ccsg.Node}
* @method getOriginalTarget
* @return {Node}
*/
getOriginalTarget:function () {
return this.originalTarget;
},
/**
* Set the original target, since target can be nil. <br/>
* Is the target that were used to run the action. <br/>
* Unless you are doing something complex, like cc.ActionManager, you should NOT call this method. <br/>
* The target is 'assigned', it is not 'retained'. <br/>
* @param {_ccsg.Node} originalTarget
*/
// Set the original target, since target can be nil.
// Is the target that were used to run the action.
// Unless you are doing something complex, like cc.ActionManager, you should NOT call this method.
setOriginalTarget:function (originalTarget) {
this.originalTarget = originalTarget;
},
/**
* get tag number.
* @method getTag
* @return {Number}
*/
getTag:function () {
@@ -178,52 +144,30 @@ cc.Action = cc._Class.extend(/** @lends cc.Action# */{
/**
* set tag number.
* @method setTag
* @param {Number} tag
*/
setTag:function (tag) {
this.tag = tag;
},
/**
* Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB, <br/>
* and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. <br/>
* This is a hack, and should be removed once JSB fixes the retain/release bug.
*/
// Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
// and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
// This is a hack, and should be removed once JSB fixes the retain/release bug.
retain:function () {
},
/**
* Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB, <br/>
* and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. <br/>
* This is a hack, and should be removed once JSB fixes the retain/release bug.
*/
// Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
// and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
// This is a hack, and should be removed once JSB fixes the retain/release bug.
release:function () {
}
});
/**
* Allocates and initializes the action.
*
* @function cc.action
* @static
* @return {cc.Action}
*
* @example
* // return {cc.Action}
* var action = cc.action();
*/
cc.action = function () {
return new cc.Action();
};
/**
* Please use cc.action instead. <br/>
* Allocates and initializes the action.
*
* @deprecated since v3.0 please use cc.action() instead.
* @static
* @returns {cc.Action}
*/
cc.Action.create = cc.action;
@@ -234,16 +178,13 @@ cc.Action.create = cc.action;
* - An action with a duration of 35.5 seconds.
*
* Infinite time actions are valid
* @class
* @extends cc.Action
* @class FiniteTimeAction
* @extends Action
*/
cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
cc.FiniteTimeAction = cc.Action.extend({
//! duration in seconds
_duration:0,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
*/
ctor:function () {
cc.Action.prototype.ctor.call(this);
this._duration = 0;
@@ -251,7 +192,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
/**
* get duration of the action. (seconds)
*
* @method getDuration
* @return {Number}
*/
getDuration:function () {
@@ -260,7 +201,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
/**
* set duration of the action. (seconds)
*
* @method setDuration
* @param {Number} duration
*/
setDuration:function (duration) {
@@ -273,7 +214,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
* - The action will be x coordinates of 0 move to 100. <br />
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
*
* @method reverse
* @return {Null}
*/
reverse:function () {
@@ -284,8 +225,8 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.FiniteTimeAction}
* @method clone
* @return {FiniteTimeAction}
*/
clone:function () {
return new cc.FiniteTimeAction();
@@ -293,23 +234,27 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{
});
/**
* @module actions
*/
/*
* Changes the speed of an action, making it take longer (speed > 1)
* or less (speed < 1) time. <br/>
* Useful to simulate 'slow motion' or 'fast forward' effect.
*
* @warning This action can't be Sequenceable because it is not an cc.IntervalAction
* @class
* @extends cc.Action
* @param {cc.ActionInterval} action
* @extends Action
* @param {ActionInterval} action
* @param {Number} speed
*/
cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
cc.Speed = cc.Action.extend({
_speed:0.0,
_innerAction:null,
/**
/*
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
* @param {cc.ActionInterval} action
* @param {ActionInterval} action
* @param {Number} speed
*/
ctor:function (action, speed) {
@@ -320,7 +265,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
action && this.initWithAction(action, speed);
},
/**
/*
* Gets the current running speed. <br />
* Will get a percentage number, compared to the original speed.
*
@@ -330,7 +275,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
return this._speed;
},
/**
/*
* alter the speed of the inner function in runtime.
*
* @param {Number} speed
@@ -339,10 +284,10 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
this._speed = speed;
},
/**
/*
* initializes the action.
*
* @param {cc.ActionInterval} action
* @param {ActionInterval} action
* @param {Number} speed
* @return {Boolean}
*/
@@ -355,71 +300,37 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
return true;
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @returns {cc.Speed}
*/
clone:function () {
var action = new cc.Speed();
action.initWithAction(this._innerAction.clone(), this._speed);
return action;
},
/**
* called before the action start. It will also set the target.
*
* @param {_ccsg.Node} target
*/
startWithTarget:function (target) {
cc.Action.prototype.startWithTarget.call(this, target);
this._innerAction.startWithTarget(target);
},
/**
* Stop the action.
*/
stop:function () {
this._innerAction.stop();
cc.Action.prototype.stop.call(this);
},
/**
* called every frame with it's delta time. <br />
* DON'T override unless you know what you are doing.
*
* @param {Number} dt
*/
step:function (dt) {
this._innerAction.step(dt * this._speed);
},
/**
* return true if the action has finished.
*
* @return {Boolean}
*/
isDone:function () {
return this._innerAction.isDone();
},
/**
* returns a reversed action. <br />
* For example: <br />
* - The action will be x coordinates of 0 move to 100. <br />
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
*
* @return {cc.Speed}
*/
reverse:function () {
return new cc.Speed(this._innerAction.reverse(), this._speed);
},
/**
/*
* Set inner Action.
* @param {cc.ActionInterval} action
* @param {ActionInterval} action
*/
setInnerAction:function (action) {
if (this._innerAction !== action) {
@@ -427,10 +338,10 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
}
},
/**
/*
* Get inner Action.
*
* @return {cc.ActionInterval}
* @return {ActionInterval}
*/
getInnerAction:function () {
return this._innerAction;
@@ -438,31 +349,25 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{
});
/**
* creates the speed action.
* Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
* or less (speed < 1) time. <br/>
* Useful to simulate 'slow motion' or 'fast forward' effect.
*
* @function cc.speed
* @param {cc.ActionInterval} action
* @warning This action can't be Sequenceable because it is not an cc.IntervalAction
*
* @method cc.speed
* @param {ActionInterval} action
* @param {Number} speed
* @return {cc.Speed}
* @return {Speed}
*/
cc.speed = function (action, speed) {
return new cc.Speed(action, speed);
};
/**
* Please use cc.speed instead.
* creates the action.
*
* @param {cc.ActionInterval} action
* @param {Number} speed
* @return {cc.Speed}
* @static
* @deprecated since v3.0 please use cc.speed() instead.
*/
cc.Speed.create = cc.speed;
/**
* cc.Follow is an action that "follows" a node.
/*
* cc.Follow is a follow action which makes its target follows another node.
*
* @example
* //example
@@ -475,7 +380,7 @@ cc.Speed.create = cc.speed;
* @property {Number} bottomBoundary - world bottomBoundary.
*
* @param {_ccsg.Node} followedNode
* @param {cc.Rect} rect
* @param {Rect} rect
* @example
* // creates the action with a set boundary
* var sprite = new _ccsg.Sprite("spriteFileName");
@@ -488,9 +393,9 @@ cc.Speed.create = cc.speed;
* this.runAction(followAction);
*
* @class
* @extends cc.Action
* @extends Action
*/
cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
cc.Follow = cc.Action.extend({
// node to follow
_followedNode:null,
// whether camera should be limited to certain area
@@ -512,7 +417,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
* creates the action with a set boundary. <br/>
* creates the action with no boundary set.
* @param {_ccsg.Node} followedNode
* @param {cc.Rect} rect
* @param {Rect} rect
*/
ctor:function (followedNode, rect) {
cc.Action.prototype.ctor.call(this);
@@ -534,12 +439,6 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
: this.initWithTarget(followedNode);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.Follow}
*/
clone:function () {
var action = new cc.Follow();
var locRect = this._worldRect;
@@ -548,7 +447,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
return action;
},
/**
/*
* Get whether camera should be limited to certain area.
*
* @return {Boolean}
@@ -557,7 +456,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
return this._boundarySet;
},
/**
/*
* alter behavior - turn on/off boundary.
*
* @param {Boolean} value
@@ -566,11 +465,11 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
this._boundarySet = value;
},
/**
/*
* initializes the action with a set boundary.
*
* @param {_ccsg.Node} followedNode
* @param {cc.Rect} [rect=]
* @param {Rect} [rect=]
* @return {Boolean}
*/
initWithTarget:function (followedNode, rect) {
@@ -613,12 +512,6 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
return true;
},
/**
* called every frame with it's delta time. <br />
* DON'T override unless you know what you are doing.
*
* @param {Number} dt
*/
step:function (dt) {
var tempPosX = this._followedNode.x;
var tempPosY = this._followedNode.y;
@@ -639,18 +532,10 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
}
},
/**
* Return true if the action has finished.
*
* @return {Boolean}
*/
isDone:function () {
return ( !this._followedNode.running );
},
/**
* Stop the action.
*/
stop:function () {
this.target = null;
cc.Action.prototype.stop.call(this);
@@ -658,37 +543,24 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
});
/**
* creates the action with a set boundary. <br/>
* creates the action with no boundary set.
* Create a follow action which makes its target follows another node.
*
* @function
* @param {_ccsg.Node} followedNode
* @param {cc.Rect} rect
* @return {cc.Follow|Null} returns the cc.Follow object on success
* @method
* @param {Node} followedNode
* @param {Rect} rect
* @return {Follow|Null} returns the cc.Follow object on success
* @example
* // example
* // creates the action with a set boundary
* var sprite = new _ccsg.Sprite("spriteFileName");
* var followAction = cc.follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height));
* this.runAction(followAction);
* var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
* node.runAction(followAction);
*
* // creates the action with no boundary set
* var sprite = new _ccsg.Sprite("spriteFileName");
* var followAction = cc.follow(sprite);
* this.runAction(followAction);
* var followAction = cc.follow(targetNode);
* node.runAction(followAction);
*/
cc.follow = function (followedNode, rect) {
return new cc.Follow(followedNode, rect);
};
/**
* Please use cc.follow instead.
* creates the action with a set boundary. <br/>
* creates the action with no boundary set.
* @param {_ccsg.Node} followedNode
* @param {cc.Rect} rect
* @return {cc.Follow|Null} returns the cc.Follow object on success
* @static
* @deprecated since v3.0 please cc.follow() instead.
*/
cc.Follow.create = cc.follow;
+9 -9
View File
@@ -27,9 +27,9 @@
/**
* Base class for cc.Camera actions
* @class
* @extends cc.ActionInterval
* @extends ActionInterval
*/
cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{
cc.ActionCamera = cc.ActionInterval.extend({
_centerXOrig:0,
_centerYOrig:0,
_centerZOrig:0,
@@ -88,7 +88,7 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{
* to copy object with deep copy.
* returns a new clone of the action
*
* @returns {cc.ActionCamera}
* @returns {ActionCamera}
*/
clone:function(){
return new cc.ActionCamera();
@@ -119,9 +119,9 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{
* @param {Number} deltaAngleX
*
* @class
* @extends cc.ActionCamera
* @extends ActionCamera
*/
cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{
cc.OrbitCamera = cc.ActionCamera.extend({
_radius: 0.0,
_deltaRadius: 0.0,
_angleZ: 0.0,
@@ -232,7 +232,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{
* to copy object with deep copy.
* returns a new clone of the action
*
* @returns {cc.ActionCamera}
* @returns {ActionCamera}
*/
clone:function(){
var a = new cc.OrbitCamera(), _t = this;
@@ -262,7 +262,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{
/**
* creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX
* @function
* @method
* @param {Number} t time
* @param {Number} radius
* @param {Number} deltaRadius
@@ -270,7 +270,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{
* @param {Number} deltaAngleZ
* @param {Number} angleX
* @param {Number} deltaAngleX
* @return {cc.OrbitCamera}
* @return {OrbitCamera}
*/
cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) {
return new cc.OrbitCamera(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX);
@@ -286,7 +286,7 @@ cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX,
* @param {Number} deltaAngleZ
* @param {Number} angleX
* @param {Number} deltaAngleX
* @return {cc.OrbitCamera}
* @return {OrbitCamera}
* @static
* @deprecated since v3.0 please use cc.orbitCamera() instead.
*/
+52 -160
View File
@@ -33,18 +33,21 @@
****************************************************************************/
/**
* @module actions
*/
/*
* Returns the Cardinal Spline position for a given set of control points, tension and time. <br />
* CatmullRom Spline formula. <br />
* s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4
*
* @function
* @param {cc.Vec2} p0
* @param {cc.Vec2} p1
* @param {cc.Vec2} p2
* @param {cc.Vec2} p3
* @param {Vec2} p0
* @param {Vec2} p1
* @param {Vec2} p2
* @param {Vec2} p3
* @param {Number} tension
* @param {Number} t
* @return {cc.Vec2}
* @return {Vec2}
*/
cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
var t2 = t * t;
@@ -65,7 +68,7 @@ cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
return cc.p(x, y);
};
/**
/*
* returns a new copy of the array reversed.
*
* @return {Array}
@@ -79,7 +82,7 @@ cc.reverseControlPoints = function (controlPoints) {
};
/**
/*
* returns a new clone of the controlPoints
*
* @param controlPoints
@@ -92,15 +95,9 @@ cc.cloneControlPoints = function (controlPoints) {
return newArray;
};
/**
* returns a new clone of the controlPoints
* @deprecated since v3.0 please use cc.cloneControlPoints() instead.
* @param controlPoints
* @returns {Array}
*/
cc.copyControlPoints = cc.cloneControlPoints;
/**
/*
* returns a point from the array
*
* @param {Array} controlPoints
@@ -112,7 +109,7 @@ cc.getControlPointAt = function (controlPoints, pos) {
return controlPoints[p];
};
/**
/*
* reverse the current control point array inline, without generating a new one <br />
*
* @param controlPoints
@@ -128,12 +125,12 @@ cc.reverseControlPointsInline = function (controlPoints) {
};
/**
* Cardinal Spline path. {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline}
/*
* Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
* Absolute coordinates.
*
* @class
* @extends cc.ActionInterval
* @class CardinalSplineTo
* @extends ActionInterval
* @param {Number} duration
* @param {Array} points array of control points
* @param {Number} tension
@@ -142,21 +139,14 @@ cc.reverseControlPointsInline = function (controlPoints) {
* //create a cc.CardinalSplineTo
* var action1 = cc.cardinalSplineTo(3, array, 0);
*/
cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# */{
/** Array of control points */
cc.CardinalSplineTo = cc.ActionInterval.extend({
/* Array of control points */
_points:null,
_deltaT:0,
_tension:0,
_previousPosition:null,
_accumulatedDiff:null,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Creates an action with a Cardinal Spline array of points and tension.
* @param {Number} duration
* @param {Array} points array of control points
* @param {Number} tension
*/
ctor: function (duration, points, tension) {
cc.ActionInterval.prototype.ctor.call(this);
@@ -164,7 +154,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
tension !== undefined && this.initWithDuration(duration, points, tension);
},
/**
/*
* initializes the action with a duration and an array of points
*
* @param {Number} duration
@@ -185,22 +175,12 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
return false;
},
/**
* returns a new clone of the action
*
* @returns {cc.CardinalSplineTo}
*/
clone:function () {
var action = new cc.CardinalSplineTo();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
return action;
},
/**
* called before the action start. It will also set the target.
*
* @param {_ccsg.Node} target
*/
startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
// Issue #1441 from cocos2d-iphone
@@ -209,11 +189,6 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
this._accumulatedDiff = cc.p(0, 0);
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
dt = this._computeEaseTime(dt);
var p, lt;
@@ -255,28 +230,22 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
this.updatePosition(newPos);
},
/**
* reverse a new cc.CardinalSplineTo. <br />
* Along the track of movement in the opposite.
*
* @return {cc.CardinalSplineTo}
*/
reverse:function () {
var reversePoints = cc.reverseControlPoints(this._points);
return cc.cardinalSplineTo(this._duration, reversePoints, this._tension);
},
/**
/*
* update position of target
*
* @param {cc.Vec2} newPos
* @param {Vec2} newPos
*/
updatePosition:function (newPos) {
this.target.setPosition(newPos);
this._previousPosition = newPos;
},
/**
/*
* Points getter
*
* @return {Array}
@@ -285,7 +254,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
return this._points;
},
/**
/*
* Points setter
*
* @param {Array} points
@@ -298,11 +267,11 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
/**
* creates an action with a Cardinal Spline array of points and tension.
*
* @function
* @method cc.cardinalSplineTo
* @param {Number} duration
* @param {Array} points array of control points
* @param {Number} tension
* @return {cc.CardinalSplineTo}
* @return {CardinalSplineTo}
*
* @example
* //create a cc.CardinalSplineTo
@@ -312,26 +281,14 @@ cc.cardinalSplineTo = function (duration, points, tension) {
return new cc.CardinalSplineTo(duration, points, tension);
};
/**
* Please use cc.cardinalSplineTo instead. <br />
* creates an action with a Cardinal Spline array of points and tension
*
* @function
* @param {Number} duration
* @param {Array} points array of control points
* @param {Number} tension
* @return {cc.CardinalSplineTo}
* @static
* @deprecated since v3.0 please use cc.cardinalSplineTo(duration, points, tension) instead.
*/
cc.CardinalSplineTo.create = cc.cardinalSplineTo;
/**
* Cardinal Spline path. {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline}
/*
* Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
* Relative coordinates.
*
* @class
* @extends cc.CardinalSplineTo
* @class CardinalSplineBy
* @extends CardinalSplineTo
* @param {Number} duration
* @param {Array} points
* @param {Number} tension
@@ -340,16 +297,9 @@ cc.CardinalSplineTo.create = cc.cardinalSplineTo;
* //create a cc.CardinalSplineBy
* var action1 = cc.cardinalSplineBy(3, array, 0);
*/
cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# */{
cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
_startPosition:null,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* creates an action with a Cardinal Spline array of points and tension.
* @param {Number} duration
* @param {Array} points
* @param {Number} tension
*/
ctor:function (duration, points, tension) {
cc.CardinalSplineTo.prototype.ctor.call(this);
this._startPosition = cc.p(0, 0);
@@ -357,22 +307,12 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy#
tension !== undefined && this.initWithDuration(duration, points, tension);
},
/**
* called before the action start. It will also set the target.
*
* @param {_ccsg.Node} target
*/
startWithTarget:function (target) {
cc.CardinalSplineTo.prototype.startWithTarget.call(this, target);
this._startPosition.x = target.getPositionX();
this._startPosition.y = target.getPositionY();
},
/**
* reverse a new cc.CardinalSplineBy
*
* @return {cc.CardinalSplineBy}
*/
reverse:function () {
var copyConfig = this._points.slice();
var current;
@@ -409,10 +349,10 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy#
return cc.cardinalSplineBy(this._duration, reverseArray, this._tension);
},
/**
/*
* update position of target
*
* @param {cc.Vec2} newPos
* @param {Vec2} newPos
*/
updatePosition:function (newPos) {
var pos = this._startPosition;
@@ -423,10 +363,10 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy#
this.target.setPosition(posX, posY);
},
/**
/*
* returns a new clone of the action
*
* @returns {cc.CardinalSplineBy}
* @returns {CardinalSplineBy}
*/
clone:function () {
var a = new cc.CardinalSplineBy();
@@ -438,57 +378,39 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy#
/**
* creates an action with a Cardinal Spline array of points and tension.
*
* @function
* @method cc.cardinalSplineBy
* @param {Number} duration
* @param {Array} points
* @param {Number} tension
*
* @return {cc.CardinalSplineBy}
* @return {CardinalSplineBy}
*/
cc.cardinalSplineBy = function (duration, points, tension) {
return new cc.CardinalSplineBy(duration, points, tension);
};
/**
* Please use cc.cardinalSplineBy instead.
* creates an action with a Cardinal Spline array of points and tension.
* @function
* @param {Number} duration
* @param {Array} points
* @param {Number} tension
* @return {cc.CardinalSplineBy}
* @static
* @deprecated since v3.0 please use cc.cardinalSplineBy(duration, points, tension);
*/
cc.CardinalSplineBy.create = cc.cardinalSplineBy;
/**
/*
* An action that moves the target with a CatmullRom curve to a destination point.<br/>
* A Catmull Rom is a Cardinal Spline with a tension of 0.5. <br/>
* {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline}
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
* Absolute coordinates.
*
* @class
* @extends cc.CardinalSplineTo
* @class CatmullRomTo
* @extends CardinalSplineTo
* @param {Number} dt
* @param {Array} points
*
* @example
* var action1 = cc.catmullRomTo(3, array);
*/
cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{
cc.CatmullRomTo = cc.CardinalSplineTo.extend({
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* creates an action with a Cardinal Spline array of points and tension.
* @param {Number} dt
* @param {Array} points
*/
ctor: function(dt, points) {
points && this.initWithDuration(dt, points);
},
/**
/*
* Initializes the action with a duration and an array of points
*
* @param {Number} dt
@@ -498,10 +420,6 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
/**
* returns a new clone of the action
* @returns {cc.CatmullRomTo}
*/
clone:function () {
var action = new cc.CatmullRomTo();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
@@ -512,10 +430,10 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{
/**
* creates an action with a Cardinal Spline array of points and tension.
*
* @function
* @method cc.catmullRomTo
* @param {Number} dt
* @param {Array} points
* @return {cc.CatmullRomTo}
* @return {CatmullRomTo}
*
* @example
* var action1 = cc.catmullRomTo(3, array);
@@ -523,26 +441,16 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{
cc.catmullRomTo = function (dt, points) {
return new cc.CatmullRomTo(dt, points);
};
/**
* Please use cc.catmullRomTo instead.
* creates an action with a Cardinal Spline array of points and tension.
*
* @param {Number} dt
* @param {Array} points
* @return {cc.CatmullRomTo}
* @static
* @deprecated since v3.0 please use cc.catmullRomTo(dt, points) instead.
*/
cc.CatmullRomTo.create = cc.catmullRomTo;
/**
/*
* An action that moves the target with a CatmullRom curve by a certain distance. <br/>
* A Catmull Rom is a Cardinal Spline with a tension of 0.5.<br/>
* http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
* Relative coordinates.
*
* @class
* @extends cc.CardinalSplineBy
* @class CatmullRomBy
* @extends CardinalSplineBy
* @param {Number} dt
* @param {Array} points
*
@@ -551,21 +459,15 @@ cc.CatmullRomTo.create = cc.catmullRomTo;
*/
cc.CatmullRomBy = cc.CardinalSplineBy.extend({
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Creates an action with a Cardinal Spline array of points and tension.
* @param {Number} dt
* @param {Array} points
*/
ctor: function(dt, points) {
cc.CardinalSplineBy.prototype.ctor.call(this);
points && this.initWithDuration(dt, points);
},
/**
/*
* initializes the action with a duration and an array of points
*
* @function
* @method
* @param {Number} dt
* @param {Array} points
*/
@@ -573,10 +475,6 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
/**
* returns a new clone of the action
* @returns {cc.CatmullRomBy}
*/
clone:function () {
var action = new cc.CatmullRomBy();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
@@ -586,20 +484,14 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({
/**
* Creates an action with a Cardinal Spline array of points and tension
* @function
* @method cc.catmullRomBy
* @param {Number} dt
* @param {Array} points
* @return {cc.CatmullRomBy}
* @return {CatmullRomBy}
* @example
* var action1 = cc.catmullRomBy(3, array);
*/
cc.catmullRomBy = function (dt, points) {
return new cc.CatmullRomBy(dt, points);
};
/**
* Please use cc.catmullRomBy instead
* Creates an action with a Cardinal Spline array of points and tension
* @static
* @deprecated since v3.0 please cc.catmullRomBy(dt, points) instead.
*/
cc.CatmullRomBy.create = cc.catmullRomBy;
File diff suppressed because it is too large Load Diff
+71 -298
View File
@@ -25,34 +25,23 @@
****************************************************************************/
/**
* Instant actions are immediate actions. They don't have a duration like.
* the CCIntervalAction actions.
* @class
* @extends cc.FiniteTimeAction
* @module actions
*/
cc.ActionInstant = cc.FiniteTimeAction.extend(/** @lends cc.ActionInstant# */{
/**
* return true if the action has finished.
* @return {Boolean}
*/
/**
* Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
* @class ActionInstant
* @extends FiniteTimeAction
*/
cc.ActionInstant = cc.FiniteTimeAction.extend({
isDone:function () {
return true;
},
/**
* called every frame with it's delta time. <br />
* DON'T override unless you know what you are doing.
* @param {Number} dt
*/
step:function (dt) {
this.update(1);
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
//nothing
},
@@ -60,60 +49,38 @@ cc.ActionInstant = cc.FiniteTimeAction.extend(/** @lends cc.ActionInstant# */{
/**
* returns a reversed action. <br />
* For example: <br />
* - The action will be x coordinates of 0 move to 100. <br />
* - The action is x coordinates of 0 move to 100. <br />
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
* @returns {cc.Action}
* @returns {Action}
*/
reverse:function(){
return this.clone();
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.FiniteTimeAction}
*/
clone:function(){
return new cc.ActionInstant();
}
});
/**
* Show the node.
* @class
* @extends cc.ActionInstant
* @module actions
*/
cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
/*
* Show the node.
* @class Show
* @extends ActionInstant
*/
cc.Show = cc.ActionInstant.extend({
update:function (dt) {
this.target.visible = true;
},
/**
* returns a reversed action. <br />
* For example: <br />
* - The action will be x coordinates of 0 move to 100. <br />
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
* @returns {cc.Hide}
*/
reverse:function () {
return new cc.Hide();
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.FiniteTimeAction}
*/
clone:function(){
return new cc.Show();
}
@@ -121,8 +88,8 @@ cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{
/**
* Show the Node.
* @function
* @return {cc.Show}
* @method cc.show
* @return {Show}
* @example
* // example
* var showAction = cc.show();
@@ -131,48 +98,23 @@ cc.show = function () {
return new cc.Show();
};
/**
* Show the Node. Please use cc.show instead.
* @static
* @deprecated since v3.0 <br /> Please use cc.show instead.
* @return {cc.Show}
*/
cc.Show.create = cc.show;
/**
/*
* Hide the node.
* @class
* @extends cc.ActionInstant
* @class Hide
* @extends ActionInstant
*/
cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{
cc.Hide = cc.ActionInstant.extend({
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.visible = false;
},
/**
* returns a reversed action. <br />
* For example: <br />
* - The action will be x coordinates of 0 move to 100. <br />
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
* @returns {cc.Show}
*/
reverse:function () {
return new cc.Show();
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.Hide}
*/
clone:function(){
return new cc.Hide();
}
@@ -180,8 +122,8 @@ cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{
/**
* Hide the node.
* @function
* @return {cc.Hide}
* @method cc.hide
* @return {Hide}
* @example
* // example
* var hideAction = cc.hide();
@@ -190,47 +132,23 @@ cc.hide = function () {
return new cc.Hide();
};
/**
* Hide the node. Please use cc.hide instead.
* @static
* @deprecated since v3.0 <br /> Please use cc.hide instead.
* @return {cc.Hide}
* @example
* // example
* var hideAction = cc.hide();
*/
cc.Hide.create = cc.hide;
/**
/*
* Toggles the visibility of a node.
* @class
* @extends cc.ActionInstant
* @class ToggleVisibility
* @extends ActionInstant
*/
cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */{
cc.ToggleVisibility = cc.ActionInstant.extend({
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.visible = !this.target.visible;
},
/**
* returns a reversed action.
* @returns {cc.ToggleVisibility}
*/
reverse:function () {
return new cc.ToggleVisibility();
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.ToggleVisibility}
*/
clone:function(){
return new cc.ToggleVisibility();
}
@@ -238,8 +156,8 @@ cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */
/**
* Toggles the visibility of a node.
* @function
* @return {cc.ToggleVisibility}
* @method cc.toggleVisibility
* @return {ToggleVisibility}
* @example
* // example
* var toggleVisibilityAction = cc.toggleVisibility();
@@ -248,18 +166,12 @@ cc.toggleVisibility = function () {
return new cc.ToggleVisibility();
};
/**
* Toggles the visibility of a node. Please use cc.toggleVisibility instead.
* @static
* @deprecated since v3.0 <br /> Please use cc.toggleVisibility instead.
* @return {cc.ToggleVisibility}
*/
cc.ToggleVisibility.create = cc.toggleVisibility;
/**
/*
* Delete self in the next frame.
* @class
* @extends cc.ActionInstant
* @class RemoveSelf
* @extends ActionInstant
* @param {Boolean} [isNeedCleanUp=true]
*
* @example
@@ -269,49 +181,25 @@ cc.ToggleVisibility.create = cc.toggleVisibility;
cc.RemoveSelf = cc.ActionInstant.extend({
_isNeedCleanUp: true,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
* @param {Boolean} [isNeedCleanUp=true]
*/
ctor:function(isNeedCleanUp){
cc.FiniteTimeAction.prototype.ctor.call(this);
isNeedCleanUp !== undefined && this.init(isNeedCleanUp);
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function(dt){
this.target.removeFromParent(this._isNeedCleanUp);
},
/**
* Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
* @param isNeedCleanUp
* @returns {boolean}
*/
init:function(isNeedCleanUp){
this._isNeedCleanUp = isNeedCleanUp;
return true;
},
/**
* returns a reversed action.
*/
reverse:function(){
return new cc.RemoveSelf(this._isNeedCleanUp);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.RemoveSelf}
*/
clone:function(){
return new cc.RemoveSelf(this._isNeedCleanUp);
}
@@ -320,9 +208,9 @@ cc.RemoveSelf = cc.ActionInstant.extend({
/**
* Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
*
* @function
* @method cc.removeSelf
* @param {Boolean} [isNeedCleanUp=true]
* @return {cc.RemoveSelf}
* @return {RemoveSelf}
*
* @example
* // example
@@ -332,41 +220,27 @@ cc.removeSelf = function(isNeedCleanUp){
return new cc.RemoveSelf(isNeedCleanUp);
};
/**
* Please use cc.removeSelf instead.
* Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
*
* @static
* @deprecated since v3.0 <br /> Please use cc.removeSelf instead.
* @param {Boolean} [isNeedCleanUp=true]
* @return {cc.RemoveSelf}
*/
cc.RemoveSelf.create = cc.removeSelf;
/**
/*
* Flips the sprite horizontally.
* @class
* @extends cc.ActionInstant
* @class FlipX
* @extends ActionInstant
* @param {Boolean} flip Indicate whether the target should be flipped or not
*
* @example
* var flipXAction = new cc.FlipX(true);
*/
cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{
cc.FlipX = cc.ActionInstant.extend({
_flippedX:false,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Create a FlipX action to flip or unflip the target.
* @param {Boolean} flip Indicate whether the target should be flipped or not
*/
ctor:function(flip){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._flippedX = false;
flip !== undefined && this.initWithFlipX(flip);
},
/**
/*
* initializes the action with a set flipX.
* @param {Boolean} flip
* @return {Boolean}
@@ -376,29 +250,14 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{
return true;
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.flippedX = this._flippedX;
},
/**
* returns a reversed action.
* @return {cc.FlipX}
*/
reverse:function () {
return new cc.FlipX(!this._flippedX);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.FiniteTimeAction}
*/
clone:function(){
var action = new cc.FlipX();
action.initWithFlipX(this._flippedX);
@@ -409,9 +268,9 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{
/**
* Create a FlipX action to flip or unflip the target.
*
* @function
* @method cc.flipX
* @param {Boolean} flip Indicate whether the target should be flipped or not
* @return {cc.FlipX}
* @return {FlipX}
* @example
* var flipXAction = cc.flipX(true);
*/
@@ -419,34 +278,19 @@ cc.flipX = function (flip) {
return new cc.FlipX(flip);
};
/**
* Plese use cc.flipX instead.
* Create a FlipX action to flip or unflip the target
*
* @static
* @deprecated since v3.0 <br /> Plese use cc.flipX instead.
* @param {Boolean} flip Indicate whether the target should be flipped or not
* @return {cc.FlipX}
*/
cc.FlipX.create = cc.flipX;
/**
/*
* Flips the sprite vertically
* @class
* @extends cc.ActionInstant
* @class FlipY
* @extends ActionInstant
* @param {Boolean} flip
* @example
* var flipYAction = new cc.FlipY(true);
*/
cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{
cc.FlipY = cc.ActionInstant.extend({
_flippedY:false,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Create a FlipY action to flip or unflip the target.
*
* @param {Boolean} flip
*/
ctor: function(flip){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._flippedY = false;
@@ -454,7 +298,7 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{
flip !== undefined && this.initWithFlipY(flip);
},
/**
/*
* initializes the action with a set flipY.
* @param {Boolean} flip
* @return {Boolean}
@@ -464,29 +308,14 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{
return true;
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.flippedY = this._flippedY;
},
/**
* returns a reversed action.
* @return {cc.FlipY}
*/
reverse:function () {
return new cc.FlipY(!this._flippedY);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.FlipY}
*/
clone:function(){
var action = new cc.FlipY();
action.initWithFlipY(this._flippedY);
@@ -497,9 +326,9 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{
/**
* Create a FlipY action to flip or unflip the target.
*
* @function
* @method cc.flipY
* @param {Boolean} flip
* @return {cc.FlipY}
* @return {FlipY}
* @example
* var flipYAction = cc.flipY(true);
*/
@@ -507,37 +336,22 @@ cc.flipY = function (flip) {
return new cc.FlipY(flip);
};
/**
* Please use cc.flipY instead
* Create a FlipY action to flip or unflip the target
*
* @static
* @deprecated since v3.0 <br /> Please use cc.flipY instead.
* @param {Boolean} flip
* @return {cc.FlipY}
*/
cc.FlipY.create = cc.flipY;
/**
/*
* Places the node in a certain position
* @class
* @extends cc.ActionInstant
* @param {cc.Vec2|Number} pos
* @class Place
* @extends ActionInstant
* @param {Vec2|Number} pos
* @param {Number} [y]
* @example
* var placeAction = new cc.Place(cc.p(200, 200));
* var placeAction = new cc.Place(200, 200);
*/
cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{
cc.Place = cc.ActionInstant.extend({
_x: 0,
_y: 0,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Creates a Place action with a position.
* @param {cc.Vec2|Number} pos
* @param {Number} [y]
*/
ctor:function(pos, y){
cc.FiniteTimeAction.prototype.ctor.call(this);
this._x = 0;
@@ -552,7 +366,7 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{
}
},
/**
/*
* Initializes a Place action with a position
* @param {number} x
* @param {number} y
@@ -564,21 +378,10 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{
return true;
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.setPosition(this._x, this._y);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.Place}
*/
clone:function(){
var action = new cc.Place();
action.initWithPosition(this._x, this._y);
@@ -588,10 +391,10 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{
/**
* Creates a Place action with a position.
* @function
* @param {cc.Vec2|Number} pos
* @method cc.place
* @param {Vec2|Number} pos
* @param {Number} [y]
* @return {cc.Place}
* @return {Place}
* @example
* // example
* var placeAction = cc.place(cc.p(200, 200));
@@ -601,22 +404,13 @@ cc.place = function (pos, y) {
return new cc.Place(pos, y);
};
/**
* Please use cc.place instead.
* Creates a Place action with a position.
* @static
* @deprecated since v3.0 <br /> Please use cc.place instead.
* @param {cc.Vec2|Number} pos
* @param {Number} [y]
* @return {cc.Place}
*/
cc.Place.create = cc.place;
/**
/*
* Calls a 'callback'.
* @class
* @extends cc.ActionInstant
* @class CallFunc
* @extends ActionInstant
* @param {function} selector
* @param {object|null} [selectorTarget]
* @param {*|null} [data] data for function, it accepts all data types.
@@ -628,12 +422,12 @@ cc.Place.create = cc.place;
* // CallFunc with data
* var finish = new cc.CallFunc(this.removeFromParentAndCleanup, this, true);
*/
cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
cc.CallFunc = cc.ActionInstant.extend({
_selectorTarget:null,
_function:null,
_data:null,
/**
/*
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Creates a CallFunc action with the callback.
* @param {function} selector
@@ -646,7 +440,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
this.initWithFunction(selector, selectorTarget, data);
},
/**
/*
* Initializes the action with a function or function and its target
* @param {function} selector
* @param {object|Null} selectorTarget
@@ -666,7 +460,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
return true;
},
/**
/*
* execute the function.
*/
execute:function () {
@@ -675,16 +469,11 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
}
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.execute();
},
/**
/*
* Get selectorTarget.
* @return {object}
*/
@@ -692,7 +481,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
return this._selectorTarget;
},
/**
/*
* Set selectorTarget.
* @param {object} sel
*/
@@ -704,12 +493,6 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
}
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.CallFunc}
*/
clone:function(){
var action = new cc.CallFunc();
action.initWithFunction(this._function, this._selectorTarget, this._data);
@@ -719,11 +502,11 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
/**
* Creates the action with the callback
* @function
* @method cc.callFunc
* @param {function} selector
* @param {object|null} [selectorTarget]
* @param {*|null} [data] data for function, it accepts all data types.
* @return {cc.CallFunc}
* @return {CallFunc}
* @example
* // example
* // CallFunc without data
@@ -736,14 +519,4 @@ cc.callFunc = function (selector, selectorTarget, data) {
return new cc.CallFunc(selector, selectorTarget, data);
};
/**
* Please use cc.callFunc instead.
* Creates the action with the callback.
* @static
* @deprecated since v3.0 <br /> Please use cc.callFunc instead.
* @param {function} selector
* @param {object|null} [selectorTarget]
* @param {*|null} [data] data for function, it accepts all data types.
* @return {cc.CallFunc}
*/
cc.CallFunc.create = cc.callFunc;
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -27,7 +27,7 @@
/**
*
* @class
* @extends cc._Class
* @extends _Class
*/
cc.ActionTweenDelegate = cc._Class.extend(/** @lends cc.ActionTweenDelegate */{
@@ -44,7 +44,7 @@ cc.ActionTweenDelegate = cc._Class.extend(/** @lends cc.ActionTweenDelegate */{
* cc.ActionTween is an action that lets you update any property of an object.
*
* @class
* @extends cc.ActionInterval
* @extends ActionInterval
* @example
* //For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then:
* var modifyWidth = cc.actionTween(2,"width",200,300)
@@ -100,7 +100,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
/**
* Start this tween with target.
* @param {cc.ActionTweenDelegate} target
* @param {ActionTweenDelegate} target
*/
startWithTarget:function (target) {
if(!target || !target.updateTweenAction)
@@ -120,7 +120,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
/**
* returns a reversed action.
* @return {cc.ActionTween}
* @return {ActionTween}
*/
reverse:function () {
return new cc.ActionTween(this.duration, this.key, this.to, this.from);
@@ -130,7 +130,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
* to copy object with deep copy.
* returns a clone of action.
*
* @return {cc.ActionTween}
* @return {ActionTween}
*/
clone:function(){
var action = new cc.ActionTween();
@@ -141,12 +141,12 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
/**
* Creates an initializes the action with the property name (key), and the from and to parameters.
* @function
* @method
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
* @return {cc.ActionTween}
* @return {ActionTween}
*/
cc.actionTween = function (duration, key, from, to) {
return new cc.ActionTween(duration, key, from, to);
@@ -161,6 +161,6 @@ cc.actionTween = function (duration, key, from, to) {
* @param {String} key
* @param {Number} from
* @param {Number} to
* @return {cc.ActionTween}
* @return {ActionTween}
*/
cc.ActionTween.create = cc.actionTween;
+4 -2
View File
@@ -929,7 +929,6 @@ var Node = cc.Class({
}
cc.eventManager.removeListener(this._touchListener);
this._touchListener.release();
this._touchListener = null;
}
},
@@ -942,7 +941,6 @@ var Node = cc.Class({
}
cc.eventManager.removeListener(this._mouseListener);
this._mouseListener.release();
this._mouseListener = null;
}
},
@@ -1107,12 +1105,16 @@ if (cc.sys.isNative) {
}, function (value) {
this.__sgNode = value;
if (this._touchListener) {
this._touchListener.retain();
cc.eventManager.removeListener(this._touchListener);
cc.eventManager.addListener(this._touchListener, this);
this._touchListener.release();
}
if (this._mouseListener) {
this._mouseListener.retain();
cc.eventManager.removeListener(this._mouseListener);
cc.eventManager.addListener(this._mouseListener, this);
this._mouseListener.release();
}
}, true);
}
+58 -53
View File
@@ -256,20 +256,41 @@ _ccsg.Label = _ccsg.Node.extend({
return this._fontSize;
},
setOverflow: function(overflow) {
if (this._overFlow === overflow) return;
this._overFlow = overflow;
if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
this._setDimensions(this._labelDimensions.width, 0);
_updateWrapText: function(overflow){
if ( overflow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
this._isWrapText = true;
}
if (this._overFlow === _ccsg.Label.Overflow.NONE) {
if (overflow === _ccsg.Label.Overflow.NONE) {
this._isWrapText = false;
this._setDimensions(0, 0);
}
},
_setOverflowBMFont: function () {
if (this._labelType === _ccsg.Label.Type.BMFont) {
if ( this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
this._setDimensions(this._labelDimensions.width, 0);
}
if (this._overFlow === _ccsg.Label.Overflow.NONE) {
this._setDimensions(0, 0);
}
this._rescaleWithOriginalFontSize();
}
},
setOverflow: function(overflow) {
if (this._overFlow === overflow) return;
this._overFlow = overflow;
this._updateWrapText(this._overFlow);
this._setOverflowBMFont();
this._rescaleWithOriginalFontSize();
this._notifyLabelSkinDirty();
},
@@ -325,9 +346,6 @@ _ccsg.Label = _ccsg.Node.extend({
//todo add bmfont here
this._labelType = _ccsg.Label.Type.BMFont;
this._initBMFontWithString(this._string, fontHandle);
if(this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
this._setDimensions(this._labelDimensions.width, 0);
}
}
},
@@ -382,37 +400,7 @@ _ccsg.Label = _ccsg.Node.extend({
return;
}
var oldWidth = this._contentSize.width;
var oldHeight = this._contentSize.height;
if (this._labelType === _ccsg.Label.Type.TTF ||
this._labelType === _ccsg.Label.Type.SystemFont) {
_ccsg.Node.prototype.setContentSize.call(this, size, height);
if (oldWidth === this._contentSize.width && oldHeight === this._contentSize.height) {
return;
}
var newWidth = size.width || size;
var newHeight = size.height || height;
this._labelWidth = newWidth;
this._labelHeight = newHeight;
this._labelDimensions.width = newWidth;
this._labelDimensions.height = newHeight;
this._maxLineWidth = newWidth;
this._notifyLabelSkinDirty();
} else if (this._labelType === _ccsg.Label.Type.BMFont) {
if (!height) {
if (oldWidth === size.width && oldHeight === size.height) {
return;
}
this._setDimensions(size.width, size.height);
} else {
if (oldWidth === size && oldHeight === height) {
return;
}
this._setDimensions(size, height);
}
}
this._setDimensions(size, height);
},
setBlendFunc: function(src, dst) {
@@ -625,18 +613,35 @@ cc.BMFontHelper = {
this._lettersInfo[letterIndex]._positionY = letterPosition.y;
},
_setDimensions: function(width, height) {
if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
height = 0;
}
if (height !== this._labelHeight || width !== this._labelWidth) {
this._labelWidth = width;
this._labelHeight = height;
this._labelDimensions.width = width;
this._labelDimensions.height = height;
_setDimensions: function(size, height) {
var newWidth = size.width || size;
var newHeight = size.height || height;
this._maxLineWidth = width;
if (this._overFlow === _ccsg.Label.Overflow.SHRINK) {
_ccsg.Node.prototype.setContentSize.call(this, size, height);
if (this._labelType === _ccsg.Label.Type.BMFont) {
if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
newHeight = 0;
}
if (this._overFlow === _ccsg.Label.Overflow.NONE) {
newWidth = 0;
newHeight = 0;
}
}
if (newHeight !== this._labelHeight || newWidth !== this._labelWidth) {
this._labelWidth = newWidth;
this._labelHeight = newHeight;
this._labelDimensions.width = newWidth;
this._labelDimensions.height = newHeight;
this._maxLineWidth = newWidth;
if (this._labelType === _ccsg.Label.Type.BMFont && this._overFlow === _ccsg.Label.Overflow.SHRINK) {
if (this._bmFontSize > 0) {
this._restoreFontSize();
}
@@ -214,11 +214,11 @@
this._splitedStrings = this._splitedStrings.concat(this._fragmentText(paragraphedStrings[i], canvasSizeX, ctx));
}
canvasSizeY = this._splitedStrings.length * this._getLineHeight();
node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
node._setDimensions(cc.size(canvasSizeX, canvasSizeY));
} else {
this._splitedStrings = paragraphedStrings;
canvasSizeY = this._splitedStrings.length * this._getLineHeight();
node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
node._setDimensions(cc.size(canvasSizeX, canvasSizeY));
}
} else if(_ccsg.Label.Overflow.SHRINK === node._overFlow) {
this._splitedStrings = paragraphedStrings;
@@ -252,12 +252,14 @@
}
} else if(_ccsg.Label.Overflow.NONE == node._overFlow) {
this._splitedStrings = paragraphedStrings;
canvasSizeX = 0;
canvasSizeY = 0;
for (var i = 0; i < paragraphedStrings.length; ++i) {
var paraLength = ctx.measureText(paragraphedStrings[i]).width;
canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength;
}
canvasSizeY = this._splitedStrings.length * this._getLineHeight();
node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
node._setDimensions(cc.size(canvasSizeX, canvasSizeY));
} else {
//others treat it as clamp
if (node._isWrapText) {
+14 -42
View File
@@ -1,7 +1,7 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2015 Chukong Technologies Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
http://www.cocos2d-x.org
@@ -66,10 +66,6 @@ var _appendProp = function (cls, name/*, isGetter*/) {
if (index < 0) {
cls.__props__.push(name);
}
// 这里不进行报错,因为重写 prop 可以是一个合法的行为,可以用于设置新的默认值。
//else {
// cc.error(cc.getClassName(cls) + '.' + name + ' is already defined!');
//}
};
var _metaClass = {
@@ -171,10 +167,6 @@ var _metaClass = {
'every getter is actually non-serialized.',
JS.getClassName(this), name);
}
if (attr.hasOwnProperty('default')) {
cc.error('%s: Can not set default value of a getter!', JS.getClassName(this));
return this;
}
}
}
}
@@ -250,7 +242,7 @@ var _metaClass = {
*/
extend: function (options) {
options.extends = this;
return FireClass(options);
return CCClass(options);
}
};
@@ -428,7 +420,7 @@ function define (className, baseClasses, mixins, constructor, options) {
function _checkCtor (ctor) {
if (CC_DEV) {
if (FireClass._isCCClass(ctor)) {
if (CCClass._isCCClass(ctor)) {
cc.error("Constructor can not be another CCClass");
return;
}
@@ -437,8 +429,8 @@ function _checkCtor (ctor) {
return;
}
if (ctor.length > 0) {
// fireball-x/dev#138: To make a unified FireClass serialization process,
// we don't allow parameters for constructor when creating instances of FireClass.
// fireball-x/dev#138: To make a unified CCClass serialization process,
// we don't allow parameters for constructor when creating instances of CCClass.
// For advance user, construct arguments can still get from 'arguments'.
cc.warn("Can not instantiate CCClass with arguments.");
return;
@@ -506,7 +498,7 @@ function _createCtor (ctor, baseClass, mixins, className, options) {
for (var b = 0; b < baseOrMixins.length; b++) {
var baseOrMixin = baseOrMixins[b];
if (baseOrMixin) {
if (FireClass._isCCClass(baseOrMixin)) {
if (CCClass._isCCClass(baseOrMixin)) {
var baseCtors = baseOrMixin.__ctors__;
if (baseCtors) {
ctors = ctors.concat(baseCtors);
@@ -632,8 +624,8 @@ function boundSuperCalls (baseClass, options) {
}
/**
* !#en Defines a FireClass using the given specification, please see [Class](/en/scripting/class/) for details.
* !#zh 定义一个 FireClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
* !#en Defines a CCClass using the given specification, please see [Class](/en/scripting/class/) for details.
* !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
*
* @class Class
* @param {Object} options
@@ -684,7 +676,7 @@ function boundSuperCalls (baseClass, options) {
// ...
};
*/
function FireClass (options) {
function CCClass (options) {
if (arguments.length === 0) {
return define();
}
@@ -796,7 +788,7 @@ function FireClass (options) {
* @return {Boolean}
* @private
*/
FireClass._isCCClass = function (constructor) {
CCClass._isCCClass = function (constructor) {
return !!constructor && (constructor.prop === _metaClass.prop);
};
@@ -805,7 +797,7 @@ FireClass._isCCClass = function (constructor) {
// @param {Function} constructor
// @private
//
//FireClass._convertToFireClass = function (constructor) {
//CCClass._convertToFireClass = function (constructor) {
// constructor.prop = _metaClass.prop;
//};
@@ -823,7 +815,7 @@ function fastDefine (className, constructor, serializableFields) {
}
}
FireClass.attr = Attr.attr;
CCClass.attr = Attr.attr;
var tmpAttrs = [];
function parseAttributes (attrs, className, propName) {
@@ -985,26 +977,6 @@ function parseAttributes (attrs, className, propName) {
}
}
if (CC_DEV) {
var watch = attrs.watch;
if (watch) {
if (typeof watch === 'object') {
for (var watchKey in watch) {
var watchCallback = watch[watchKey];
if (typeof watchCallback === 'function') {
result.push(Attr.Watch(watchKey.split(' '), watchCallback));
}
else {
cc.error(ERR_Type, 'value', 'watch object', 'function');
}
}
}
else {
cc.error(ERR_Type, 'watch', className + '.' + propName, 'object');
}
}
}
return result;
}
@@ -1013,9 +985,9 @@ function parseAttributes (attrs, className, propName) {
* @return {Function}
* @deprecated
*/
FireClass.extend = FireClass;
CCClass.extend = CCClass;
cc.Class = FireClass;
cc.Class = CCClass;
module.exports = {
instantiateProps: instantiateProps,
+20 -14
View File
@@ -300,43 +300,49 @@ cc.loader = cc.loader || (function () {
callback = option;
url = urlAppendTimestamp(url);
var isNew = false;
var img = this.getRes(url);
if (!img) {
img = new Image();
isNew = true;
if (opt.isCrossOrigin && location.origin !== "file://")
img.crossOrigin = "Anonymous";
img.src = url;
}
if (img.complete && img.naturalWidth > 0) {
if (!isNew && img.complete && img.naturalWidth > 0) {
callback && callback(null, img);
} else {
var loadCallback = function () {
img.removeEventListener('load', loadCallback, false);
img.removeEventListener('error', errorCallback, false);
}
else {
function loadCallback () {
img.removeEventListener('load', loadCallback);
img.removeEventListener('error', errorCallback);
if (callback)
callback(null, img);
};
}
var self = this;
var errorCallback = function () {
img.removeEventListener('load', loadCallback, false);
img.removeEventListener('error', errorCallback, false);
function errorCallback () {
img.removeEventListener('load', loadCallback);
img.removeEventListener('error', errorCallback);
if(img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous"){
if (img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous") {
opt.isCrossOrigin = false;
self.release(url);
cc.loader.loadImg(url, opt, callback);
}else{
}
else {
typeof callback === "function" && callback("load image failed");
}
};
}
img.addEventListener("load", loadCallback);
img.addEventListener("error", errorCallback);
}
if (isNew) {
img.src = url;
}
return img;
},
+40 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
Copyright (c) 2013-2016 Chukong Technologies Inc.
http://www.cocos2d-x.org
@@ -27,6 +27,10 @@
var JS = require('./js');
var isPlainEmptyObj = require('./utils').isPlainEmptyObj_DEV;
/**
* @class Class
*/
/**
* Tag the class with any meta attributes, then return all current attributes assigned to it.
* This function holds only the attributes, not their implementations.
@@ -36,6 +40,8 @@ var isPlainEmptyObj = require('./utils').isPlainEmptyObj_DEV;
* @param {String} propertyName - the name of property or function, used to retrieve the attributes
* @param {Object} [attributes] - the attribute table to mark, new attributes will merged with existed attributes. Attribute whose key starts with '_' will be ignored.
* @return {Object|Undefined} return all attributes associated with the property. if none undefined will be returned
* @static
* @private
* @example {@link utils/api/engine/docs/cocos2d/core/platform/attribute/attr.js}
*/
function attr (constructor, propertyName, attributes) {
@@ -101,6 +107,39 @@ function attr (constructor, propertyName, attributes) {
}
}
/**
* @module cc
*/
/**
* Specify that the input value must be integer in Inspector.
* Also used to indicates that the elements in array should be type integer.
* @property {string} Integer
* @readonly
*/
cc.Integer = 'Integer';
/**
* Indicates that the elements in array should be type double.
* @property {string} Float
* @readonly
*/
cc.Float = 'Float';
/**
* Indicates that the elements in array should be type boolean.
* @property {string} Boolean
* @readonly
*/
cc.Boolean = 'Boolean';
/**
* Indicates that the elements in array should be type string.
* @property {string} String
* @readonly
*/
cc.String = 'String';
/*
BuiltinAttributes: {
default: defaultValue,
@@ -267,22 +306,6 @@ function Nullable (boolPropName, hasValueByDefault) {
};
}
//
// @method Watch
// @param {String} names - the name of target property to watch, array is also acceptable.
// @param {Function} callback - the callback function to invoke when target property(s) is changed.
// @param {Object} callback.param object - the instance object which contains watching property(s).
// @param {Object} callback.param element - the property element which displays watching property(s).
// @return {object} the attribute
// @private
//
function Watch (names, callback) {
return {
watch: [].concat(names), // array of property name to watch
watchCallback: callback
};
}
function Range (min, max) {
return { min: min, max: max };
}
@@ -296,6 +319,5 @@ module.exports = {
RawType: RawType,
ScriptUuid: {}, // the value will be represented as a uuid string
Nullable: Nullable,
Watch: Watch,
Range: Range
};
+1 -1
View File
@@ -402,7 +402,7 @@ var _Deserializer = (function () {
var klass = null;
if (serialized.__type__) {
// Type Object (including FireClass)
// Type Object (including CCClass)
klass = self._classFinder(serialized.__type__);
if (!klass) {
+9 -1
View File
@@ -26,7 +26,7 @@
var Attr = require('./attribute');
// 增加预处理属性这个步骤的目的是降低 FireClass 的实现难度,将比较稳定的通用逻辑和一些需求比较灵活的属性需求分隔开。
// 增加预处理属性这个步骤的目的是降低 CCClass 的实现难度,将比较稳定的通用逻辑和一些需求比较灵活的属性需求分隔开。
var SerializableAttrs = {
url: {
@@ -193,6 +193,14 @@ module.exports = function (properties, className, cls) {
properties[propName] = val;
}
if (val) {
if (CC_EDITOR && 'default' in val) {
if (val.get) {
cc.error('The "default" value of "%s.%s" should not be used with a "get" function.', className, propName);
}
else if (val.set) {
cc.error('The "default" value of "%s.%s" should not be used with a "set" function.', className, propName);
}
}
if (!val.override && cls.__props__.indexOf(propName) !== -1 && CC_DEV) {
// check override
var baseClass = cc.js.getClassName(getBaseClassWherePropertyDefined(propName, cls));
+11 -1
View File
@@ -597,7 +597,17 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
});
var sgNode = this._sgNode = new _ccsg.Node();
sgNode.retain();
if (cc.sys.isNative) {
sgNode.retain();
var entity = this;
sgNode.onEnter = function () {
_ccsg.Node.prototype.onEnter.call(this);
if (!entity._active) {
cc.director.getActionManager().pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
};
}
if (!cc.game._isCloning) {
sgNode.cascadeOpacity = true;
}
+4 -1
View File
@@ -141,7 +141,10 @@ cc.js.mixin(cc.director, {
this.runWithScene(sgScene);
}
else {
this.replaceScene(sgScene);
// Delay to avoid issues like transition in event callback
this.once(cc.Director.EVENT_AFTER_DRAW, function () {
this.replaceScene(sgScene);
});
}
// Activate