From 6f62507737e5bd9fc5b9d6a4f8b472d31b58ba21 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Mon, 24 Mar 2014 15:20:55 +0800
Subject: [PATCH 0001/1564] Issue #3942: remove copy function from some action
and set action.copy shows deprecate information
---
cocos2d/actions/CCAction.js | 1 +
cocos2d/actions/CCActionInstant.js | 10 ----------
cocos2d/actions/CCActionInterval.js | 9 ---------
3 files changed, 1 insertion(+), 19 deletions(-)
diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js
index 4c70204a5a..c491925748 100644
--- a/cocos2d/actions/CCAction.js
+++ b/cocos2d/actions/CCAction.js
@@ -58,6 +58,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{
* @return {object}
*/
copy:function () {
+ cc.log("copy is deprecated. Please use clone instead.");
return this.clone();
},
diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js
index 485e64f999..9cb42db9b4 100644
--- a/cocos2d/actions/CCActionInstant.js
+++ b/cocos2d/actions/CCActionInstant.js
@@ -433,16 +433,6 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
}
},
- copy:function() {
- var n = new cc.CallFunc();
- if(this._selectorTarget){
- n.initWithTarget(this._callFunc, this._selectorTarget, this._data)
- }else if(this._function){
- n.initWithFunction(this._function);
- }
- return n;
- },
-
clone:function(){
var action = new cc.CallFunc();
if(this._selectorTarget){
diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js
index 115b1ed7cb..bcb8f506c8 100644
--- a/cocos2d/actions/CCActionInterval.js
+++ b/cocos2d/actions/CCActionInterval.js
@@ -274,14 +274,6 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
*/
reverse:function () {
return cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
- },
-
- /**
- * to copy object with deep copy.
- * @return {object}
- */
- copy:function () {
- return this.clone();
}
});
/** helper constructor to create an array of sequenceable actions
@@ -320,7 +312,6 @@ cc.Sequence._actionOneTwo = function (actionOne, actionTwo) {
return sequence;
};
-
/** Repeats an action a number of times.
* To repeat an action forever use the CCRepeatForever action.
* @class
From f7bb09e5f87b9b2bccc2ed26a7583984f71cb48e Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Wed, 26 Mar 2014 14:21:56 +0800
Subject: [PATCH 0002/1564] Issue #3943: use _this replace this for Google
compiler in advance mode
---
cocos2d/actions/CCAction.js | 35 +--
cocos2d/actions/CCActionCatmullRom.js | 27 +--
cocos2d/actions/CCActionEase.js | 12 +-
cocos2d/actions/CCActionInstant.js | 11 +-
cocos2d/actions/CCActionInterval.js | 310 +++++++++++++-------------
5 files changed, 201 insertions(+), 194 deletions(-)
diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js
index c491925748..d26088f59e 100644
--- a/cocos2d/actions/CCAction.js
+++ b/cocos2d/actions/CCAction.js
@@ -454,37 +454,38 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{
if(!followedNode)
throw "cc.Follow.initWithAction(): followedNode must be non nil";
+ var _this = this;
rect = rect || cc.rect(0, 0, 0, 0);
- this._followedNode = followedNode;
- this._worldRect = rect;
+ _this._followedNode = followedNode;
+ _this._worldRect = rect;
- this._boundarySet = !cc._rectEqualToZero(rect);
+ _this._boundarySet = !cc._rectEqualToZero(rect);
- this._boundaryFullyCovered = false;
+ _this._boundaryFullyCovered = false;
var winSize = cc.director.getWinSize();
- this._fullScreenSize = cc.p(winSize.width, winSize.height);
- this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5);
+ _this._fullScreenSize = cc.p(winSize.width, winSize.height);
+ _this._halfScreenSize = cc.pMult(_this._fullScreenSize, 0.5);
- if (this._boundarySet) {
- this.leftBoundary = -((rect.x + rect.width) - this._fullScreenSize.x);
- this.rightBoundary = -rect.x;
- this.topBoundary = -rect.y;
- this.bottomBoundary = -((rect.y + rect.height) - this._fullScreenSize.y);
+ if (_this._boundarySet) {
+ _this.leftBoundary = -((rect.x + rect.width) - _this._fullScreenSize.x);
+ _this.rightBoundary = -rect.x;
+ _this.topBoundary = -rect.y;
+ _this.bottomBoundary = -((rect.y + rect.height) - _this._fullScreenSize.y);
- if (this.rightBoundary < this.leftBoundary) {
+ if (_this.rightBoundary < _this.leftBoundary) {
// screen width is larger than world's boundary width
//set both in the middle of the world
- this.rightBoundary = this.leftBoundary = (this.leftBoundary + this.rightBoundary) / 2;
+ _this.rightBoundary = _this.leftBoundary = (_this.leftBoundary + _this.rightBoundary) / 2;
}
- if (this.topBoundary < this.bottomBoundary) {
+ if (_this.topBoundary < _this.bottomBoundary) {
// screen width is larger than world's boundary width
//set both in the middle of the world
- this.topBoundary = this.bottomBoundary = (this.topBoundary + this.bottomBoundary) / 2;
+ _this.topBoundary = _this.bottomBoundary = (_this.topBoundary + _this.bottomBoundary) / 2;
}
- if ((this.topBoundary == this.bottomBoundary) && (this.leftBoundary == this.rightBoundary))
- this._boundaryFullyCovered = true;
+ if ((_this.topBoundary == _this.bottomBoundary) && (_this.leftBoundary == _this.rightBoundary))
+ _this._boundaryFullyCovered = true;
}
return true;
},
diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js
index fa2169f5c5..860c81584b 100644
--- a/cocos2d/actions/CCActionCatmullRom.js
+++ b/cocos2d/actions/CCActionCatmullRom.js
@@ -130,13 +130,14 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
* Constructor
*/
ctor:function () {
- cc.ActionInterval.prototype.ctor.call(this);
-
- this._points = [];
- this._deltaT = 0;
- this._tension = 0;
- this._previousPosition = null;
- this._accumulatedDiff = null;
+ var _this = this;
+ cc.ActionInterval.prototype.ctor.call(_this);
+
+ _this._points = [];
+ _this._deltaT = 0;
+ _this._tension = 0;
+ _this._previousPosition = null;
+ _this._accumulatedDiff = null;
},
/**
@@ -172,19 +173,19 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
// Issue #1441 from cocos2d-iphone
- this._deltaT = 1 / (this._points.length - 1);
- this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
- this._accumulatedDiff = cc.p(0, 0);
+ _this._deltaT = 1 / (_this._points.length - 1);
+ _this._previousPosition = cc.p(_this.target.getPositionX(), _this.target.getPositionY());
+ _this._accumulatedDiff = cc.p(0, 0);
},
/**
* @param {Number} time
*/
update:function (time) {
- var p, lt;
- var ps = this._points;
+ var p, lt, ps = this._points;
// eg.
// p..p..p..p..p..p..p
// 1..2..3..4..5..6..7
diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js
index 2024dab47c..8464c118b3 100644
--- a/cocos2d/actions/CCActionEase.js
+++ b/cocos2d/actions/CCActionEase.js
@@ -533,7 +533,6 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{
update:function (time1) {
time1 = time1===0 || time1==1 ? time1 : -0.5 * (Math.cos(Math.PI * time1) - 1);
this._inner.update(time1);
-
},
clone:function(){
@@ -632,7 +631,7 @@ cc.EaseElastic.create = function (action, period) {
/**
* Ease Elastic In action.
- * @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
+ * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
* @class
* @extends cc.EaseElastic
*/
@@ -746,7 +745,7 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{
*/
update:function (time1) {
var newT = 0;
- var locPeriod = this._period
+ var locPeriod = this._period;
if (time1 === 0 || time1 == 1) {
newT = time1;
} else {
@@ -890,7 +889,7 @@ cc.EaseBounceIn.create = function (action) {
};
/**
* cc.EaseBounceOut action.
- * @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
+ * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
* @class
* @extends cc.EaseBounce
*/
@@ -933,7 +932,7 @@ cc.EaseBounceOut.create = function (action) {
/**
* cc.EaseBounceInOut action.
- * @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
+ * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
* @class
* @extends cc.EaseBounce
*/
@@ -1072,7 +1071,7 @@ cc.EaseBackOut.create = function (action) {
/**
* cc.EaseBackInOut action.
- * @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
+ * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
* @class
* @extends cc.ActionEase
*/
@@ -1082,7 +1081,6 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{
*/
update:function (time1) {
var overshoot = 1.70158 * 1.525;
-
time1 = time1 * 2;
if (time1 < 1) {
this._inner.update((time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2);
diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js
index 9cb42db9b4..30ed635028 100644
--- a/cocos2d/actions/CCActionInstant.js
+++ b/cocos2d/actions/CCActionInstant.js
@@ -367,11 +367,12 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
_data:null,
ctor:function(){
- cc.FiniteTimeAction.prototype.ctor.call(this);
- this._selectorTarget = null;
- this._callFunc = null;
- this._function = null;
- this._data = null;
+ var _this = this;
+ cc.FiniteTimeAction.prototype.ctor.call(_this);
+ _this._selectorTarget = null;
+ _this._callFunc = null;
+ _this._function = null;
+ _this._data = null;
},
/**
diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js
index bcb8f506c8..1aea35d174 100644
--- a/cocos2d/actions/CCActionInterval.js
+++ b/cocos2d/actions/CCActionInterval.js
@@ -95,17 +95,18 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
* @param {Number} dt delta time in seconds
*/
step:function (dt) {
- if (this._firstTick) {
- this._firstTick = false;
- this._elapsed = 0;
+ var _this = this;
+ if (_this._firstTick) {
+ _this._firstTick = false;
+ _this._elapsed = 0;
} else
- this._elapsed += dt;
+ _this._elapsed += dt;
//this.update((1 > (this._elapsed / this._duration)) ? this._elapsed / this._duration : 1);
//this.update(Math.max(0, Math.min(1, this._elapsed / Math.max(this._duration, cc.FLT_EPSILON))));
- var t = this._elapsed / (this._duration > 0.0000001192092896 ? this._duration : 0.0000001192092896);
+ var t = _this._elapsed / (_this._duration > 0.0000001192092896 ? _this._duration : 0.0000001192092896);
t = (1 > t ? t : 1);
- this.update(t > 0 ? t : 0);
+ _this.update(t > 0 ? t : 0);
},
/**
@@ -225,8 +226,9 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
* @param {Number} time time in seconds
*/
update:function (time) {
+ var _this = this;
var new_t, found = 0;
- var locSplit = this._split, locActions = this._actions, locLast = this._last;
+ var locSplit = _this._split, locActions = _this._actions, locLast = _this._last;
if (time < locSplit) {
// action[0]
new_t = (locSplit !== 0) ? time / locSplit : 1;
@@ -246,7 +248,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
if (locLast === -1) {
// action[0] was skipped, execute it.
- locActions[0].startWithTarget(this.target);
+ locActions[0].startWithTarget(_this.target);
locActions[0].update(1);
locActions[0].stop();
}
@@ -263,10 +265,10 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
// Last action found and it is done
if (locLast !== found)
- locActions[found].startWithTarget(this.target);
+ locActions[found].startWithTarget(_this.target);
locActions[found].update(new_t);
- this._last = found;
+ _this._last = found;
},
/**
@@ -325,12 +327,13 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{
_innerAction:null, //CCFiniteTimeAction
ctor:function () {
- cc.ActionInterval.prototype.ctor.call(this);
- this._times = 0;
- this._total = 0;
- this._nextDt = 0;
- this._actionInstant = false;
- this._innerAction = null;
+ var _this = this;
+ cc.ActionInterval.prototype.ctor.call(_this);
+ _this._times = 0;
+ _this._total = 0;
+ _this._nextDt = 0;
+ _this._actionInstant = false;
+ _this._innerAction = null;
},
/**
@@ -384,28 +387,29 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{
* @param {Number} time time in seconds
*/
update:function (time) {
- var locInnerAction = this._innerAction;
- var locDuration = this._duration;
- var locTimes = this._times;
- var locNextDt = this._nextDt;
+ var _this = this;
+ var locInnerAction = _this._innerAction;
+ var locDuration = _this._duration;
+ var locTimes = _this._times;
+ var locNextDt = _this._nextDt;
if (time >= locNextDt) {
- while (time > locNextDt && this._total < locTimes) {
+ while (time > locNextDt && _this._total < locTimes) {
locInnerAction.update(1);
- this._total++;
+ _this._total++;
locInnerAction.stop();
- locInnerAction.startWithTarget(this.target);
+ locInnerAction.startWithTarget(_this.target);
locNextDt += locInnerAction.getDuration() / locDuration;
- this._nextDt = locNextDt;
+ _this._nextDt = locNextDt;
}
// fix for issue #1288, incorrect end value of repeat
- if (time >= 1.0 && this._total < locTimes)
- this._total++;
+ if (time >= 1.0 && _this._total < locTimes)
+ _this._total++;
// don't set a instantaction back or update it, it has no use because it has no duration
- if (this._actionInstant) {
- if (this._total == locTimes) {
+ if (_this._actionInstant) {
+ if (_this._total == locTimes) {
locInnerAction.update(1);
locInnerAction.stop();
} else {
@@ -594,21 +598,18 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{
if(!action1 || !action2)
throw "cc.Spawn.initWithTwoActions(): arguments must all be non null" ;
- var ret = false;
-
- var d1 = action1.getDuration();
- var d2 = action2.getDuration();
+ var _this = this, ret = false;
+ var d1 = action1.getDuration(), d2 = action2.getDuration();
- if (this.initWithDuration(Math.max(d1, d2))) {
- this._one = action1;
- this._two = action2;
+ if (_this.initWithDuration(Math.max(d1, d2))) {
+ _this._one = action1;
+ _this._two = action2;
if (d1 > d2) {
- this._two = cc.Sequence._actionOneTwo(action2, cc.DelayTime.create(d1 - d2));
+ _this._two = cc.Sequence._actionOneTwo(action2, cc.DelayTime.create(d1 - d2));
} else if (d1 < d2) {
- this._one = cc.Sequence._actionOneTwo(action1, cc.DelayTime.create(d2 - d1));
+ _this._one = cc.Sequence._actionOneTwo(action1, cc.DelayTime.create(d2 - d1));
}
-
ret = true;
}
return ret;
@@ -709,14 +710,15 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{
_diffAngleY:0,
ctor:function () {
- cc.ActionInterval.prototype.ctor.call(this);
- this._dstAngleX = 0;
- this._startAngleX = 0;
- this._diffAngleX = 0;
+ var _this = this;
+ cc.ActionInterval.prototype.ctor.call(_this);
+ _this._dstAngleX = 0;
+ _this._startAngleX = 0;
+ _this._diffAngleX = 0;
- this._dstAngleY = 0;
- this._startAngleY = 0;
- this._diffAngleY = 0;
+ _this._dstAngleY = 0;
+ _this._startAngleY = 0;
+ _this._diffAngleY = 0;
},
/**
@@ -781,9 +783,10 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{
* @param {Number} time time in seconds
*/
update:function (time) {
- if (this.target) {
- this.target.rotationX = this._startAngleX + this._diffAngleX * time;
- this.target.rotationY = this._startAngleY + this._diffAngleY * time;
+ var _this = this;
+ if (_this.target) {
+ _this.target.rotationX = _this._startAngleX + _this._diffAngleX * time;
+ _this.target.rotationY = _this._startAngleY + _this._diffAngleY * time;
}
}
});
@@ -861,9 +864,10 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{
* @param {Number} time
*/
update:function (time) {
- if (this.target) {
- this.target.rotationX = this._startAngleX + this._angleX * time;
- this.target.rotationY = this._startAngleY + this._angleY * time;
+ var _this = this;
+ if (_this.target) {
+ _this.target.rotationX = _this._startAngleX + _this._angleX * time;
+ _this.target.rotationY = _this._startAngleY + _this._angleY * time;
}
},
@@ -942,27 +946,29 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{
* @param {Number} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
var locPosX = target.getPositionX();
var locPosY = target.getPositionY();
- this._previousPosition.x = locPosX;
- this._previousPosition.y = locPosY;
- this._startPosition.x = locPosX;
- this._startPosition.y = locPosY;
+ _this._previousPosition.x = locPosX;
+ _this._previousPosition.y = locPosY;
+ _this._startPosition.x = locPosX;
+ _this._startPosition.y = locPosY;
},
/**
* @param {Number} time time in seconds
*/
update:function (time) {
+ var _this = this;
if (this.target) {
- var x = this._positionDelta.x * time;
- var y = this._positionDelta.y * time;
- var locStartPosition = this._startPosition;
+ var x = _this._positionDelta.x * time;
+ var y = _this._positionDelta.y * time;
+ var locStartPosition = _this._startPosition;
if (cc.ENABLE_STACKABLE_ACTIONS) {
- var targetX = this.target.getPositionX();
- var targetY = this.target.getPositionY();
- var locPreviousPosition = this._previousPosition;
+ var targetX = _this.target.getPositionX();
+ var targetY = _this.target.getPositionY();
+ var locPreviousPosition = _this._previousPosition;
locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
@@ -970,9 +976,9 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{
y = y + locStartPosition.y;
locPreviousPosition.x = x;
locPreviousPosition.y = y;
- this.target.setPosition(x, y);
+ _this.target.setPosition(x, y);
} else {
- this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
+ _this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
}
}
},
@@ -1042,9 +1048,10 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.MoveBy.prototype.startWithTarget.call(this, target);
- this._positionDelta.x = this._endPosition.x - target.getPositionX();
- this._positionDelta.y = this._endPosition.y - target.getPositionY();
+ var _this = this;
+ cc.MoveBy.prototype.startWithTarget.call(_this, target);
+ _this._positionDelta.x = _this._endPosition.x - target.getPositionX();
+ _this._positionDelta.y = _this._endPosition.y - target.getPositionY();
}
});
/**
@@ -1077,15 +1084,16 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{
_deltaY:0,
ctor:function () {
- 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;
+ var _this = this;
+ 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;
},
/**
@@ -1118,21 +1126,22 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
- this._startSkewX = target.skewX % 180;
- this._deltaX = this._endSkewX - this._startSkewX;
- if (this._deltaX > 180)
- this._deltaX -= 360;
- if (this._deltaX < -180)
- this._deltaX += 360;
+ _this._startSkewX = target.skewX % 180;
+ _this._deltaX = _this._endSkewX - _this._startSkewX;
+ if (_this._deltaX > 180)
+ _this._deltaX -= 360;
+ if (_this._deltaX < -180)
+ _this._deltaX += 360;
- this._startSkewY = target.skewY % 360;
- this._deltaY = this._endSkewY - this._startSkewY;
- if (this._deltaY > 180)
- this._deltaY -= 360;
- if (this._deltaY < -180)
- this._deltaY += 360;
+ _this._startSkewY = target.skewY % 360;
+ _this._deltaY = _this._endSkewY - _this._startSkewY;
+ if (_this._deltaY > 180)
+ _this._deltaY -= 360;
+ if (_this._deltaY < -180)
+ _this._deltaY += 360;
},
/**
@@ -1194,11 +1203,12 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.SkewTo.prototype.startWithTarget.call(this, target);
- this._deltaX = this._skewX;
- this._deltaY = this._skewY;
- this._endSkewX = this._startSkewX + this._deltaX;
- this._endSkewY = this._startSkewY + this._deltaY;
+ var _this = this;
+ cc.SkewTo.prototype.startWithTarget.call(_this, target);
+ _this._deltaX = _this._skewX;
+ _this._deltaY = _this._skewY;
+ _this._endSkewX = _this._startSkewX + _this._deltaX;
+ _this._endSkewY = _this._startSkewY + _this._deltaY;
},
/**
@@ -1237,12 +1247,13 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
_previousPosition:null,
ctor:function () {
- 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;
+ var _this = this;
+ 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;
},
/**
* @param {Number} duration
@@ -1252,11 +1263,12 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
* @return {Boolean}
*/
initWithDuration:function (duration, position, height, jumps) {
- if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
- this._delta.x = position.x;
- this._delta.y = position.y;
- this._height = height;
- this._jumps = jumps;
+ var _this = this;
+ if (cc.ActionInterval.prototype.initWithDuration.call(_this, duration)) {
+ _this._delta.x = position.x;
+ _this._delta.y = position.y;
+ _this._height = height;
+ _this._jumps = jumps;
return true;
}
return false;
@@ -1276,13 +1288,14 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
var locPosX = target.getPositionX();
var locPosY = target.getPositionY();
- this._previousPosition.x = locPosX;
- this._previousPosition.y = locPosY;
- this._startPosition.x = locPosX;
- this._startPosition.y = locPosY;
+ _this._previousPosition.x = locPosX;
+ _this._previousPosition.y = locPosY;
+ _this._startPosition.x = locPosX;
+ _this._startPosition.y = locPosY;
},
/**
@@ -1445,13 +1458,14 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
var locPosX = target.getPositionX();
var locPosY = target.getPositionY();
- this._previousPosition.x = locPosX;
- this._previousPosition.y = locPosY;
- this._startPosition.x = locPosX;
- this._startPosition.y = locPosY;
+ _this._previousPosition.x = locPosX;
+ _this._previousPosition.y = locPosY;
+ _this._startPosition.x = locPosX;
+ _this._startPosition.y = locPosY;
},
/**
@@ -1460,18 +1474,10 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{
update:function (time) {
if (this.target) {
var locConfig = this._config;
- var xa = 0;
- var xb = locConfig[0].x;
- var xc = locConfig[1].x;
- var xd = locConfig[2].x;
-
- var ya = 0;
- var yb = locConfig[0].y;
- var yc = locConfig[1].y;
- var yd = locConfig[2].y;
+ var xa = 0, xb = locConfig[0].x, xc = locConfig[1].x, xd = locConfig[2].x;
+ var ya = 0, yb = locConfig[0].y, yc = locConfig[1].y, yd = locConfig[2].y;
- var x = cc.bezierAt(xa, xb, xc, xd, time);
- var y = cc.bezierAt(ya, yb, yc, yd, time);
+ var x = cc.bezierAt(xa, xb, xc, xd, time), y = cc.bezierAt(ya, yb, yc, yd, time);
var locStartPosition = this._startPosition;
if (cc.ENABLE_STACKABLE_ACTIONS) {
@@ -1562,9 +1568,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{
*/
startWithTarget:function (target) {
cc.BezierBy.prototype.startWithTarget.call(this, target);
- var locStartPos = this._startPosition;
- var locToConfig = this._toConfig;
- var locConfig = this._config;
+ var locStartPos = this._startPosition, locToConfig = this._toConfig, locConfig = this._config;
locConfig[0] = cc.pSub(locToConfig[0], locStartPos);
locConfig[1] = cc.pSub(locToConfig[1], locStartPos);
@@ -1603,15 +1607,16 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{
_deltaY:0,
ctor:function () {
- 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;
+ var _this = this;
+ 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;
},
/**
@@ -1643,11 +1648,12 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{
* @param {cc.Node} target
*/
startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
- this._startScaleX = target.scaleX;
- this._startScaleY = target.scaleY;
- this._deltaX = this._endScaleX - this._startScaleX;
- this._deltaY = this._endScaleY - this._startScaleY;
+ var _this = this;
+ cc.ActionInterval.prototype.startWithTarget.call(_this, target);
+ _this._startScaleX = target.scaleX;
+ _this._startScaleY = target.scaleY;
+ _this._deltaX = _this._endScaleX - _this._startScaleX;
+ _this._deltaY = _this._endScaleY - _this._startScaleY;
},
/**
@@ -2069,13 +2075,14 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{
_fromB:0,
ctor:function () {
- cc.ActionInterval.prototype.ctor.call(this);
- this._deltaR = 0;
- this._deltaG = 0;
- this._deltaB = 0;
- this._fromR = 0;
- this._fromG = 0;
- this._fromB = 0;
+ var _this = this;
+ cc.ActionInterval.prototype.ctor.call(_this);
+ _this._deltaR = 0;
+ _this._deltaG = 0;
+ _this._deltaB = 0;
+ _this._fromR = 0;
+ _this._fromG = 0;
+ _this._fromB = 0;
},
/**
@@ -2412,8 +2419,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{
*/
reverse:function () {
var locAnimation = this._animation;
- var oldArray = locAnimation.getFrames();
- var newArray = [];
+ var oldArray = locAnimation.getFrames(), newArray = [];
cc.arrayVerifyType(oldArray, cc.AnimationFrame);
if (oldArray.length > 0) {
for (var i = oldArray.length - 1; i >= 0; i--) {
From d62fbba8860e8fcf7cfd36216d9b4574a97ed1ee Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Fri, 11 Apr 2014 20:49:19 +0800
Subject: [PATCH 0003/1564] Fixed #4706: Fixed a problem due to IE incompatible
issue
---
cocos2d/core/platform/CCClass.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js
index fa61107aae..95228e2e5d 100644
--- a/cocos2d/core/platform/CCClass.js
+++ b/cocos2d/core/platform/CCClass.js
@@ -253,8 +253,8 @@ cc.defineGetterSetter = function (proto, prop, getter, setter, getterName, sette
for (var i = 0; i < props.length; i++) {
var name = props[i];
- if( (Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(proto, name)
- : proto.__lookupGetter__(name))
+ if( (proto.__lookupGetter__ ? proto.__lookupGetter__(name)
+ : Object.getOwnPropertyDescriptor(proto, name))
|| typeof proto[name] !== "function" )
continue;
From 990d24ded053bc4db8668db790b2ac7b909790c5 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Sat, 12 Apr 2014 14:00:08 +0800
Subject: [PATCH 0004/1564] Issue #4757: add an assert to cc.Sprite for debug
friendly.
---
CCDebugger.js | 1 +
cocos2d/core/sprites/CCSprite.js | 5 ++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/CCDebugger.js b/CCDebugger.js
index 5e0a5e2b87..d8b633c160 100644
--- a/CCDebugger.js
+++ b/CCDebugger.js
@@ -105,6 +105,7 @@ cc._LogInfos = {
Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",
Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",
+ Sprite_initWithSpriteFrameName1: " is null, please check.",
Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null",
Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",
Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null",
diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js
index 9b3ee418ea..bacfd2c6a0 100644
--- a/cocos2d/core/sprites/CCSprite.js
+++ b/cocos2d/core/sprites/CCSprite.js
@@ -444,10 +444,9 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
* sprite.initWithSpriteFrameName("grossini_dance_01.png");
*/
initWithSpriteFrameName:function (spriteFrameName) {
-
- cc.assert(cc._LogInfos.Sprite_initWithSpriteFrameName);
-
+ cc.assert(spriteFrameName, cc._LogInfos.Sprite_initWithSpriteFrameName);
var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName);
+ cc.assert(frame, spriteFrameName + cc._LogInfos.Sprite_initWithSpriteFrameName1);
return this.initWithSpriteFrame(frame);
},
From 840f4ccedfda4752ef20b17b62fc98bbf3d1f64a Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Sat, 12 Apr 2014 17:27:17 +0800
Subject: [PATCH 0005/1564] Issue #4757: update the version number of
Cocos2d-html5 v3.0 alpha2
---
tools/build.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/build.xml b/tools/build.xml
index c54e093bbd..61eb5c0599 100644
--- a/tools/build.xml
+++ b/tools/build.xml
@@ -5,7 +5,7 @@
classpath="./compiler/compiler.jar"/>
+ debug="false" output="./../lib/cocos2d-html5-v3.0-alpha2-min.js">
@@ -231,7 +231,7 @@
+ debug="false" output="./../lib/cocos2d-html5-v3.0-alpha2-core-min.js">
From a54fb8c9aa023154fcdbf04756c5ccda04d7ee4a Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Sat, 12 Apr 2014 18:33:24 +0800
Subject: [PATCH 0006/1564] Issue #4757: update the build.xml of Jsdoc_toolkit
---
tools/jsdoc_toolkit/build.xml | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml
index 0198fe08c0..a47b4b2f11 100644
--- a/tools/jsdoc_toolkit/build.xml
+++ b/tools/jsdoc_toolkit/build.xml
@@ -20,10 +20,12 @@
+
-
+
+
@@ -32,11 +34,15 @@
+
-
+
+
+
+
@@ -56,11 +62,6 @@
-
-
-
-
-
@@ -124,10 +125,6 @@
-
-
-
-
From 41375625437095ff225daffeb6e5f1440901507b Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Sat, 12 Apr 2014 19:49:43 +0800
Subject: [PATCH 0007/1564] Fixed #4774: auto full screen switch function added
to cc.view
---
cocos2d/core/platform/CCEGLView.js | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js
index 4541c1a005..959bd5d836 100644
--- a/cocos2d/core/platform/CCEGLView.js
+++ b/cocos2d/core/platform/CCEGLView.js
@@ -46,6 +46,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
// The visible rect in content's coordinate in point
_visibleRect: null,
_retinaEnabled: false,
+ _autoFullScreen: true,
// The device's pixel ratio (for retina displays)
_devicePixelRatio: 1,
// the view name
@@ -242,6 +243,23 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
return this._retinaEnabled;
},
+ /**
+ * If enabled, the application will try automatically to enter full screen mode on mobile devices
+ * You can pass true as parameter to enable it and disable it by passing false
+ * @param {Boolean} enabled Enable or disable auto full screen on mobile devices
+ */
+ enableAutoFullScreen: function(enabled) {
+ this._autoFullScreen = enabled ? true : false;
+ },
+
+ /**
+ * Check whether auto full screen is enabled.
+ * @return {Boolean}
+ */
+ isAutoFullScreenEnabled: function() {
+ return this._autoFullScreen;
+ },
+
/**
* Force destroying EGL view, subclass must implement this method.
*/
@@ -627,7 +645,7 @@ cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{
_setupContainer: function (view, w, h) {
var frame = view._frame;
- if (cc.sys.isMobile && frame == document.documentElement) {
+ if (this._autoFullScreen && cc.sys.isMobile && frame == document.documentElement) {
// Automatically full screen when user touches on mobile version
cc.screen.autoFullScreen(frame);
}
From 08228aa804070c6b934c26e154ca64334e7e9d48 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Mon, 14 Apr 2014 10:20:55 +0800
Subject: [PATCH 0008/1564] Issue #4757: update the CHANGELOG.txt and
AUTHORS.txt
---
AUTHORS.txt | 21 ++++++++++++++++-----
CHANGELOG.txt | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/AUTHORS.txt b/AUTHORS.txt
index ce58b34302..87d25c8517 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -10,20 +10,21 @@ Core Developers:
Dingping Lv (David Lv)
- Shengxiang Chen (Nero Chan)
-
Ricardo Quesada
- Xingsen Ma
-
Huabin LING
+ Sijie Wang
+
+ Jialong Zhai
+
Contributors:
Name GithubID Main contribution
Dali Kilani @dadilcool added instruction to read me
Chris @hannon235 added node.js api for box2d
+ added SocketIO and SocketIO tests
Jason Aeschliman @jaeschliman fixed cc.Node setposition
@@ -112,6 +113,7 @@ XiaoJun Zheng @SmallAiTT _getResType error fix
refactor some public functions in cc to private
add node.js scripts for publishing game
refactor cc.CCBReader
+ cc.view bug fix
Guozhu Cheng @bengol cc.SimpleAudioEngine bug fix
@@ -157,10 +159,19 @@ Andor Salga @asalga typo fix
erykwalder @erykwalder Function.prototype.bind bug fix
ZippoLag @ZippoLag cc.Application.getCurrentLanguage bug fix
+ typo fix
+
+Asano @LaercioAsano cc.Node bug fix
+
+Bruno Assarisse @bassarisse cc.LabelBMFont bug fix
+
+Retired Core Developers:
+ Shengxiang Chen (Nero Chan)
+ Xingsen Ma
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.
-Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups!
+Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!
Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions.
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index c51ecbc9e7..19a2bcbeb8 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,46 @@
ChangeLog:
+Cocos2d-html5-v3.0 alpha2 @ April.14, 2014
+
+* Minimize the size of core from 254k to 113k after google closure advanced compiling.
+* Make engine classes can be constructed via `new` with the same parameters as create functions.
+* Make engine classes extendable directly via ctor.
+* Made cc.DrawNode support some DrawingPrimitive's drawing function on WebGL mode.
+* cc.Sprite supports creating a sprite through external URL.
+* Add SocketIO to framework's external.
+* Add the warning information to notice developers that their project.json cannot be loaded or parsed.
+* Add retina display support to cc.Editbox.
+* cc.Node's pauseSchedulerAndActions and resumeSchedulerAndActions are deprecated, please use pause and resume instead.
+* Add render mode checking to 3D action classes.
+* Use undefined check in cc.loader for better performance.
+* Sync cc.eventManager to the latest version of Cocos2d-x v3.0 Stable.
+* ccui.Layout's doLayout function has been set to private function "_doLayout".
+* Rename all Uppercase functions to lowercase in CCMacro.js.
+* Add more necessary GL constants in engine.
+* Rename ccs.comAttribute's `getCString` function to `getString`.
+
+* Bugs fix:
+ 1. Fixed ccs.comAttribute API incompatible issue
+ 2. Fixed a bug of CocoStudio's data reader that getting isTween value is incorrect when the attribute value is false.
+ 3. Fixed a bug of Sprite that it stops to work when its texture doesn't preload and its parent is a SpriteBatchNode
+ 4. Fixed a bug in CCBoot.js that console.error is invalid on firefox.
+ 5. Fixed a bug of cc.LabelBMFont that it's multiline works incorrectly.
+ 6. Fixed a bug that Touches event doesn't work in release mode on IE browser.
+ 7. Fixed a bug that cc.winSize has not been reset after cc.view.setDesignResolutionSize.
+ 8. Fixed typo error in ccui.Widget.TOUCH_BEGAN
+ 9. Fixed a bug of cc.MenuItemSprite.create that its can't create item when the length of arguments equals 4.
+ 10. Fixed a bug of cc.loader that it need to set value before calling the callback.
+ 11. Fixed a bug of cc.log that it doesn't work in IE9
+ 12. Fixed IE incompatible issue with __lookupGetter__
+ 13. Fixed a bug of cc.Node that it returns a reference of _position in getPosition
+ 14. Fixed a bug of cc.ClippingNode that its _super is undefined
+ 15. Fixed a bug of inputManager's touch event in IE browser
+ 16. Add callback null check to avoid bugs in cc.textureCache.addImage.
+ 17. Fixed some comment errors of framework.
+
+* Known Issues:
+ 1. EventListener is not extendable.
+
+
Cocos2d-html5-v3.0 alpha @ March.15, 2014
* Refactor some properties of all rendering classes with getter setter for providing javascript user friendly APIs.
From df51ddd35ab7df493b1f3affda18b2232d1f5d99 Mon Sep 17 00:00:00 2001
From: VisualSJ
Date: Mon, 14 Apr 2014 13:47:22 +0800
Subject: [PATCH 0009/1564] Fixed a bug that ant. Variable name changed
---
extensions/ccui/base-classes/UIWidget.js | 354 +++++++++---------
extensions/ccui/layouts/UILayout.js | 98 +++--
extensions/ccui/uiwidgets/UIButton.js | 128 +++----
extensions/ccui/uiwidgets/UICheckBox.js | 88 ++---
extensions/ccui/uiwidgets/UILoadingBar.js | 30 +-
extensions/ccui/uiwidgets/UISlider.js | 52 +--
extensions/ccui/uiwidgets/UIText.js | 116 +++---
extensions/ccui/uiwidgets/UITextAtlas.js | 42 +--
extensions/ccui/uiwidgets/UITextBMFont.js | 44 +--
extensions/ccui/uiwidgets/UITextField.js | 108 +++---
.../uiwidgets/scroll-widget/UIScrollView.js | 162 ++++----
11 files changed, 605 insertions(+), 617 deletions(-)
diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js
index 3ae6c0e6ac..7ff359a4de 100644
--- a/extensions/ccui/base-classes/UIWidget.js
+++ b/extensions/ccui/base-classes/UIWidget.js
@@ -77,9 +77,9 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
_reorderWidgetChildDirty: false,
_hitted: false,
_nodes: null,
- _touchListener : null,
- _color:null,
- _className:"Widget",
+ _touchListener: null,
+ _color: null,
+ _className: "Widget",
_flippedX: false,
_flippedY: false,
ctor: function () {
@@ -91,9 +91,9 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
this._focus = false;
this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE;
this._updateEnabled = false;
- this._touchStartPos = cc.p(0,0);
- this._touchMovePos = cc.p(0,0);
- this._touchEndPos = cc.p(0,0);
+ this._touchStartPos = cc.p(0, 0);
+ this._touchMovePos = cc.p(0, 0);
+ this._touchEndPos = cc.p(0, 0);
this._touchEventListener = null;
this._touchEventSelector = null;
this._name = "default";
@@ -106,13 +106,13 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
this._widgetChildren = [];
this._affectByClipping = false;
this._sizeType = ccui.Widget.SIZE_ABSOLUTE;
- this._sizePercent = cc.p(0,0);
+ this._sizePercent = cc.p(0, 0);
this.positionType = ccui.Widget.POSITION_ABSOLUTE;
- this._positionPercent = cc.p(0,0);
+ this._positionPercent = cc.p(0, 0);
this._reorderWidgetChildDirty = false;
this._hitted = false;
this._nodes = [];
- this._color = cc.color(255,255,255,255);
+ this._color = cc.color(255, 255, 255, 255);
this._touchListener = null;
this._flippedX = false;
this._flippedY = false;
@@ -123,7 +123,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* @returns {boolean}
*/
init: function () {
- if (cc.Node.prototype.init.call(this)){
+ if (cc.Node.prototype.init.call(this)) {
this._layoutParameterDictionary = {};
this._widgetChildren = [];
this.initRenderer();
@@ -141,7 +141,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
visit: function (ctx) {
if (this._enabled) {
- cc.Node.prototype.visit.call(this,ctx);
+ cc.Node.prototype.visit.call(this, ctx);
}
},
@@ -181,12 +181,12 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* @param {Number} tag
*/
addChild: function (widget, zOrder, tag) {
- if(widget instanceof ccui.Widget){
+ if (widget instanceof ccui.Widget) {
cc.Node.prototype.addChild.call(this, widget, zOrder, tag);
this._widgetChildren.push(widget);
return;
}
- if(widget instanceof cc.Node){
+ if (widget instanceof cc.Node) {
cc.log("Please use addNode to add a CCNode.");
return;
}
@@ -197,7 +197,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* @param tag
* @returns {ccui.Widget}
*/
- getChildByTag:function(tag){
+ getChildByTag: function (tag) {
var __children = this._widgetChildren;
if (__children != null) {
for (var i = 0; i < __children.length; i++) {
@@ -227,7 +227,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
getWidgetParent: function () {
var widget = this.getParent();
- if(widget instanceof ccui.Widget){
+ if (widget instanceof ccui.Widget) {
return widget;
}
return null;
@@ -239,7 +239,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* @param {Boolean} cleanup
*/
removeChild: function (widget, cleanup) {
- if(!(widget instanceof ccui.Widget)){
+ if (!(widget instanceof ccui.Widget)) {
cc.log("child must a type of ccui.Widget");
return;
}
@@ -388,50 +388,50 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
var locW = this._customSize.width = size.width;
var locH = this._customSize.height = size.height;
if (this._ignoreSize) {
- locW = this.width;
- locH = this.height;
+ locW = this.width;
+ locH = this.height;
}
- this._size.width = locW;
- this._size.height = locH;
+ this._size.width = locW;
+ this._size.height = locH;
- if(this._running){
- var widgetParent = this.getWidgetParent();
- if(widgetParent){
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ if (widgetParent) {
locW = widgetParent.width;
- locH = widgetParent.height;
- }else{
- locW = this._parent.width;
- locH = this._parent.height;
+ locH = widgetParent.height;
+ } else {
+ locW = this._parent.width;
+ locH = this._parent.height;
}
- this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0;
- this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0;
+ this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0;
+ this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0;
+ }
+ this.onSizeChanged();
+ },
+ _setWidth: function (w) {
+ var locW = this._customSize.width = w;
+ this._ignoreSize && (locW = this.width);
+ this._size.width = locW;
+
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ locW = widgetParent ? widgetParent.width : this._parent.width;
+ this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0;
+ }
+ this.onSizeChanged();
+ },
+ _setHeight: function (h) {
+ var locH = this._customSize.height = h;
+ this._ignoreSize && (locH = this.height);
+ this._size.height = locH;
+
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ locH = widgetParent ? widgetParent.height : this._parent.height;
+ this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0;
}
this.onSizeChanged();
},
- _setWidth: function (w) {
- var locW = this._customSize.width = w;
- this._ignoreSize && (locW = this.width);
- this._size.width = locW;
-
- if(this._running){
- var widgetParent = this.getWidgetParent();
- locW = widgetParent ? widgetParent.width : this._parent.width;
- this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0;
- }
- this.onSizeChanged();
- },
- _setHeight: function (h) {
- var locH = this._customSize.height = h;
- this._ignoreSize && (locH = this.height);
- this._size.height = locH;
-
- if(this._running){
- var widgetParent = this.getWidgetParent();
- locH = widgetParent ? widgetParent.height : this._parent.height;
- this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0;
- }
- this.onSizeChanged();
- },
/**
* Changes the percent that is widget's percent size
@@ -453,35 +453,35 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
}
}
if (!this._ignoreSize) {
- this._size.width = width;
- this._size.height = height;
+ this._size.width = width;
+ this._size.height = height;
}
this._customSize.width = width;
this._customSize.height = height;
this.onSizeChanged();
},
- _setWidthPercent: function (percent) {
- this._sizePercent.x = percent;
- var width = this._customSize.width;
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- width = (widgetParent ? widgetParent.width : this._parent.width) * percent;
- }
- this._ignoreSize || (this._size.width = width);
- this._customSize.width = width;
- this.onSizeChanged();
- },
- _setHeightPercent: function (percent) {
- this._sizePercent.y = percent;
- var height = this._customSize.height;
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- height = (widgetParent ? widgetParent.height : this._parent.height) * percent;
- }
- this._ignoreSize || (this._size.height = height);
- this._customSize.height = height;
- this.onSizeChanged();
- },
+ _setWidthPercent: function (percent) {
+ this._sizePercent.x = percent;
+ var width = this._customSize.width;
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ width = (widgetParent ? widgetParent.width : this._parent.width) * percent;
+ }
+ this._ignoreSize || (this._size.width = width);
+ this._customSize.width = width;
+ this.onSizeChanged();
+ },
+ _setHeightPercent: function (percent) {
+ this._sizePercent.y = percent;
+ var height = this._customSize.height;
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ height = (widgetParent ? widgetParent.height : this._parent.height) * percent;
+ }
+ this._ignoreSize || (this._size.height = height);
+ this._customSize.height = height;
+ this.onSizeChanged();
+ },
/**
* update size and position
@@ -501,9 +501,9 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
var pSize, spx = 0, spy = 0;
var widgetParent = this.getWidgetParent();
- if (widgetParent){
+ if (widgetParent) {
pSize = widgetParent.getSize();
- }else{
+ } else {
pSize = this._parent.getContentSize();
}
if (pSize.width > 0) {
@@ -517,11 +517,11 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
break;
case ccui.Widget.SIZE_PERCENT:
var widgetParent = this.getWidgetParent();
- var cSize = cc.size(0,0);
- if (widgetParent){
+ var cSize = cc.size(0, 0);
+ if (widgetParent) {
cSize.width = widgetParent.getSize().width * this._sizePercent.x;
cSize.height = widgetParent.getSize().height * this._sizePercent.y;
- }else{
+ } else {
cSize.width = this._parent.getContentSize().width * this._sizePercent.x;
cSize.height = this._parent.getContentSize().height * this._sizePercent.y;
}
@@ -546,15 +546,15 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
case ccui.Widget.POSITION_ABSOLUTE:
var widgetParent = this.getWidgetParent();
var pSize;
- if(widgetParent){
+ if (widgetParent) {
pSize = widgetParent.getSize();
- }else{
+ } else {
pSize = this._parent.getContentSize();
}
- if(pSize.width<=0||pSize.height<=0){
+ if (pSize.width <= 0 || pSize.height <= 0) {
this._positionPercent.x = 0;
this._positionPercent.y = 0;
- }else{
+ } else {
this._positionPercent.x = absPos.x / pSize.width;
this._positionPercent.y = absPos.y / pSize.height;
}
@@ -562,9 +562,9 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
case ccui.Widget.POSITION_PERCENT:
var widgetParent = this.getWidgetParent();
var pSize;
- if(widgetParent){
+ if (widgetParent) {
pSize = widgetParent.getSize();
- }else{
+ } else {
pSize = this._parent.getContentSize();
}
absPos = cc.p(pSize.width * this._positionPercent.x, pSize.height * this._positionPercent.y);
@@ -629,7 +629,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* Get custom size
* @returns {cc.Size}
*/
- getCustomSize:function(){
+ getCustomSize: function () {
return this._customSize
},
@@ -640,19 +640,19 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
getSizePercent: function () {
return this._sizePercent;
},
- _getWidthPercent: function () {
- return this._sizePercent.x;
- },
- _getHeightPercent: function () {
- return this._sizePercent.y;
- },
+ _getWidthPercent: function () {
+ return this._sizePercent.x;
+ },
+ _getHeightPercent: function () {
+ return this._sizePercent.y;
+ },
/**
* Gets world position of widget.
* @returns {cc.Point}
*/
getWorldPosition: function () {
- return this.convertToWorldSpace(cc.p(0,0));
+ return this.convertToWorldSpace(cc.p(0, 0));
},
/**
@@ -680,12 +680,12 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
getContentSize: function () {
return this._size;
},
- _getWidth: function () {
- return this._size.width;
- },
- _getHeight: function () {
- return this._size.height;
- },
+ _getWidth: function () {
+ return this._size.width;
+ },
+ _getHeight: function () {
+ return this._size.height;
+ },
/**
* Sets whether the widget is touch enabled
@@ -696,7 +696,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
return;
}
this._touchEnabled = enable;
- if(this._touchEnabled){
+ if (this._touchEnabled) {
this._touchListener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
@@ -705,7 +705,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
onTouchEnded: this.onTouchEnded.bind(this)
});
cc.eventManager.addListener(this._touchListener, this);
- }else{
+ } else {
cc.eventManager.removeListener(this._touchListener);
}
},
@@ -793,7 +793,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
if (this._brightStyle == style) {
return;
}
- style = style|| ccui.Widget.BRIGHT_STYLE_NORMAL;
+ style = style || ccui.Widget.BRIGHT_STYLE_NORMAL;
this._brightStyle = style;
switch (this._brightStyle) {
case ccui.Widget.BRIGHT_STYLE_NORMAL:
@@ -835,12 +835,12 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
},
- onTouchBegan: function (touch,event) {
+ onTouchBegan: function (touch, event) {
var touchPoint = touch.getLocation();
this._touchStartPos.x = touchPoint.x;
this._touchStartPos.y = touchPoint.y;
- this._hitted = this.isEnabled() && this.isTouchEnabled()&& this.hitTest(touchPoint)&& this.clippingParentAreaContainPoint(touchPoint);
- if(!this._hitted){
+ this._hitted = this.isEnabled() && this.isTouchEnabled() && this.hitTest(touchPoint) && this.clippingParentAreaContainPoint(touchPoint);
+ if (!this._hitted) {
return false;
}
this.setFocused(true);
@@ -852,7 +852,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
return !this._touchPassedEnabled;
},
- onTouchMoved: function (touch,event) {
+ onTouchMoved: function (touch, event) {
var touchPoint = touch.getLocation();
this._touchMovePos.x = touchPoint.x;
this._touchMovePos.y = touchPoint.y;
@@ -865,7 +865,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
},
- onTouchEnded: function (touch,event) {
+ onTouchEnded: function (touch, event) {
var touchPoint = touch.getLocation();
this._touchEndPos.x = touchPoint.x;
this._touchEndPos.y = touchPoint.y;
@@ -1026,10 +1026,10 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
this._positionPercent.y = 0;
}
else {
- if(posY){
+ if (posY) {
this._positionPercent.x = pos / pSize.width;
this._positionPercent.y = posY / pSize.height;
- }else{
+ } else {
this._positionPercent.x = pos.x / pSize.width;
this._positionPercent.y = pos.y / pSize.height;
}
@@ -1040,34 +1040,34 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
cc.Node.prototype.setPosition.apply(this, arguments);
},
- setPositionX: function (x) {
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- if (widgetParent) {
- var pw = widgetParent.width;
- if (pw <= 0)
- this._positionPercent.x = 0;
- else
- this._positionPercent.x = x / pw;
- }
- }
-
- cc.Node.prototype.setPositionX.call(this, x);
- },
- setPositionY: function (y) {
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- if (widgetParent) {
- var ph = widgetParent.height;
- if (ph <= 0)
- this._positionPercent.y = 0;
- else
- this._positionPercent.y = y / ph;
- }
- }
-
- cc.Node.prototype.setPositionY.call(this, y);
- },
+ setPositionX: function (x) {
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ if (widgetParent) {
+ var pw = widgetParent.width;
+ if (pw <= 0)
+ this._positionPercent.x = 0;
+ else
+ this._positionPercent.x = x / pw;
+ }
+ }
+
+ cc.Node.prototype.setPositionX.call(this, x);
+ },
+ setPositionY: function (y) {
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ if (widgetParent) {
+ var ph = widgetParent.height;
+ if (ph <= 0)
+ this._positionPercent.y = 0;
+ else
+ this._positionPercent.y = y / ph;
+ }
+ }
+
+ cc.Node.prototype.setPositionY.call(this, y);
+ },
/**
* Changes the position (x,y) of the widget
@@ -1077,34 +1077,34 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
this._positionPercent = percent;
if (this._running) {
var widgetParent = this.getWidgetParent();
- if(widgetParent){
+ if (widgetParent) {
var parentSize = widgetParent.getSize();
this.setPosition(parentSize.width * this._positionPercent.x, parentSize.height * this._positionPercent.y);
}
}
},
- _setXPercent: function (percent) {
- this._positionPercent.x = percent;
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- if(widgetParent){
- var absX = widgetParent.width * percent;
- this.setPositionX(absX);
- }
- }
- },
- _setYPercent: function (percent) {
- this._positionPercent.y = percent;
- if (this._running) {
- var widgetParent = this.getWidgetParent();
- if(widgetParent){
- var absY = widgetParent.height * percent;
- this.setPositionY(absY);
- }
- }
- },
-
- updateAnchorPoint:function(){
+ _setXPercent: function (percent) {
+ this._positionPercent.x = percent;
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ if (widgetParent) {
+ var absX = widgetParent.width * percent;
+ this.setPositionX(absX);
+ }
+ }
+ },
+ _setYPercent: function (percent) {
+ this._positionPercent.y = percent;
+ if (this._running) {
+ var widgetParent = this.getWidgetParent();
+ if (widgetParent) {
+ var absY = widgetParent.height * percent;
+ this.setPositionY(absY);
+ }
+ }
+ },
+
+ updateAnchorPoint: function () {
this.setAnchorPoint(this.getAnchorPoint());
},
@@ -1115,12 +1115,12 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
getPositionPercent: function () {
return this._positionPercent;
},
- _getXPercent: function () {
- return this._positionPercent.x;
- },
- _getYPercent: function () {
- return this._positionPercent.y;
- },
+ _getXPercent: function () {
+ return this._positionPercent.x;
+ },
+ _getYPercent: function () {
+ return this._positionPercent.y;
+ },
/**
* Changes the position type of the widget
@@ -1172,11 +1172,11 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
return this._flippedY;
},
- updateFlippedX:function(){
+ updateFlippedX: function () {
},
- updateFlippedY:function(){
+ updateFlippedY: function () {
},
@@ -1316,7 +1316,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
var widgetChildren = model.getChildren();
for (var i = 0; i < widgetChildren.length; i++) {
var locChild = widgetChildren[i];
- if(locChild instanceof ccui.Widget){
+ if (locChild instanceof ccui.Widget) {
this.addChild(locChild.clone());
}
}
@@ -1363,7 +1363,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
}
this.onSizeChanged();
},
-
+
/*temp action*/
setActionTag: function (tag) {
this._actionTag = tag;
@@ -1390,8 +1390,8 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
* Get color
* @returns {cc.Color}
*/
- getColor:function(){
- return cc.color(this._color.r,this._color.g,this._color.b,this._color.a) ;
+ getColor: function () {
+ return cc.color(this._color.r, this._color.g, this._color.b, this._color.a);
},
/**
@@ -1433,7 +1433,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{
}
});
-window._p = ccui.Widget.prototype;
+var _p = ccui.Widget.prototype;
// Extended properties
/** @expose */
@@ -1479,7 +1479,7 @@ cc.defineGetterSetter(_p, "name", _p.getName, _p.setName);
_p.actionTag;
cc.defineGetterSetter(_p, "actionTag", _p.getActionTag, _p.setActionTag);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UIWidget.
diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js
index 875092e05a..356f39e9af 100644
--- a/extensions/ccui/layouts/UILayout.js
+++ b/extensions/ccui/layouts/UILayout.js
@@ -51,14 +51,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
_layoutType: null,
_doLayoutDirty: false,
_clippingRectDirty: false,
- _clippingType : null,
+ _clippingType: null,
_clippingStencil: null,
_handleScissor: false,
_scissorRectDirty: false,
_clippingRect: null,
_clippingParent: null,
- _className:"Layout",
- _backGroundImageColor:null,
+ _className: "Layout",
+ _backGroundImageColor: null,
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._clippingEnabled = false;
@@ -89,7 +89,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
this._backGroundImageColor = cc.color(255, 255, 255, 255);
},
init: function () {
- if (cc.Node.prototype.init.call(this)){
+ if (cc.Node.prototype.init.call(this)) {
this._layoutParameterDictionary = {};
this._widgetChildren = [];
this.initRenderer();
@@ -102,8 +102,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
}
return false;
},
- initStencil : null,
- _initStencilForWebGL:function(){
+ initStencil: null,
+ _initStencilForWebGL: function () {
this._clippingStencil = cc.DrawNode.create();
ccui.Layout._init_once = true;
if (ccui.Layout._init_once) {
@@ -138,7 +138,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* @param {Number} tag
*/
addChild: function (widget, zOrder, tag) {
- if(!(widget instanceof ccui.Widget)){
+ if (!(widget instanceof ccui.Widget)) {
throw "the child add to Layout must a type of cc.Widget";
}
this.supplyTheLayoutParameterLackToChild(widget);
@@ -151,8 +151,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* @param {ccui.Widget} widget
* @param {Boolean} cleanup
*/
- removeChild:function(widget,cleanup){
- ccui.Widget.prototype.removeChild.call(this, widget,cleanup);
+ removeChild: function (widget, cleanup) {
+ ccui.Widget.prototype.removeChild.call(this, widget, cleanup);
this._doLayoutDirty = true;
},
@@ -160,7 +160,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Remove all widget
* @param {Boolean} cleanup
*/
- removeAllChildren:function(cleanup){
+ removeAllChildren: function (cleanup) {
ccui.Widget.prototype.removeAllChildren.call(this, cleanup);
this._doLayoutDirty = true;
},
@@ -190,7 +190,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
}
}
else {
- cc.Node.prototype.visit.call(this,ctx);
+ cc.Node.prototype.visit.call(this, ctx);
}
},
@@ -199,7 +199,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
this._doLayout();
},
- stencilClippingVisit : null,
+ stencilClippingVisit: null,
_stencilClippingVisitForWebGL: function (ctx) {
var gl = ctx || cc._renderContext;
@@ -295,7 +295,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
// draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(CCPointZero, ccpFromSize([[CCDirector sharedDirector] winSize]), ccc4f(1, 1, 1, 1));
- cc._drawingUtil.drawSolidRect(cc.p(0,0), cc.pFromSize(cc.director.getWinSize()), cc.color(255, 255, 255, 255));
+ cc._drawingUtil.drawSolidRect(cc.p(0, 0), cc.pFromSize(cc.director.getWinSize()), cc.color(255, 255, 255, 255));
///////////////////////////////////
// DRAW CLIPPING STENCIL
@@ -427,14 +427,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
}
},
- _godhelpme:false,
+ _godhelpme: false,
_cangodhelpme: function (godhelpme) {
if (godhelpme === true || godhelpme === false)
cc.ClippingNode.prototype._godhelpme = godhelpme;
return cc.ClippingNode.prototype._godhelpme;
},
- scissorClippingVisit : null,
+ scissorClippingVisit: null,
_scissorClippingVisitForWebGL: function (ctx) {
var clippingRect = this.getClippingRect();
var gl = ctx || cc._renderContext;
@@ -489,7 +489,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get clipping type
* @returns {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR}
*/
- getClippingType : function(){
+ getClippingType: function () {
return this._clippingType;
},
@@ -511,7 +511,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
},
getClippingRect: function () {
- if (this._clippingRectDirty){
+ if (this._clippingRectDirty) {
this._handleScissor = true;
var worldPos = this.convertToWorldSpace(cc.p(0, 0));
var t = this.nodeToWorldTransform();
@@ -632,7 +632,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get background image is use scale9 renderer.
* @returns {Boolean}
*/
- isBackGroundImageScale9Enabled:function(){
+ isBackGroundImageScale9Enabled: function () {
return this._backGroundScale9Enabled;
},
@@ -684,7 +684,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get background image cap insets.
* @returns {cc.Rect}
*/
- getBackGroundImageCapInsets:function(){
+ getBackGroundImageCapInsets: function () {
return this._backGroundImageCapInsets;
},
@@ -804,7 +804,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get color type.
* @returns {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT}
*/
- getBackGroundColorType:function(){
+ getBackGroundColorType: function () {
return this._colorType;
},
@@ -840,7 +840,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get back ground color
* @returns {cc.Color}
*/
- getBackGroundColor:function(){
+ getBackGroundColor: function () {
return this._color;
},
@@ -848,7 +848,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get back ground start color
* @returns {cc.Color}
*/
- getBackGroundStartColor:function(){
+ getBackGroundStartColor: function () {
return this._startColor;
},
@@ -856,7 +856,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get back ground end color
* @returns {cc.Color}
*/
- getBackGroundEndColor:function(){
+ getBackGroundEndColor: function () {
return this._endColor;
},
@@ -884,7 +884,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get background opacity value.
* @returns {Number}
*/
- getBackGroundColorOpacity:function(){
+ getBackGroundColorOpacity: function () {
return this._opacity;
},
@@ -904,7 +904,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
* Get background color value.
* @returns {cc.Point}
*/
- getBackGroundColorVector:function(){
+ getBackGroundColorVector: function () {
return this._alongVector;
},
@@ -1274,7 +1274,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
default:
break;
}
- var locRelativeWidgetMargin,locRelativeWidgetLPAlign;
+ var locRelativeWidgetMargin, locRelativeWidgetLPAlign;
var locMargin = locLayoutParameter.getMargin();
if (locRelativeWidgetLP) {
locRelativeWidgetMargin = locRelativeWidgetLP.getMargin();
@@ -1319,8 +1319,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT) {
locFinalPosY += locRelativeWidgetMargin.top;
}
locFinalPosY += locMargin.left;
@@ -1330,8 +1329,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT) {
locFinalPosY += locRelativeWidgetMargin.top;
}
break;
@@ -1340,8 +1338,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT) {
locFinalPosY += locRelativeWidgetMargin.top;
}
locFinalPosX -= locMargin.right;
@@ -1351,8 +1348,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) {
locFinalPosX -= locRelativeWidgetMargin.left;
}
locFinalPosY -= locMargin.top;
@@ -1362,8 +1358,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) {
locFinalPosX -= locRelativeWidgetMargin.left;
}
break;
@@ -1372,8 +1367,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_NONE
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) {
locFinalPosX -= locRelativeWidgetMargin.left;
}
locFinalPosY += locMargin.bottom;
@@ -1383,8 +1377,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosX += locMargin.left;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) {
locFinalPosX += locRelativeWidgetMargin.right;
}
locFinalPosY -= locMargin.top;
@@ -1393,8 +1386,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosX += locMargin.left;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) {
locFinalPosX += locRelativeWidgetMargin.right;
}
break;
@@ -1402,8 +1394,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosX += locMargin.left;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) {
locFinalPosX += locRelativeWidgetMargin.right;
}
locFinalPosY += locMargin.bottom;
@@ -1413,8 +1404,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosY -= locMargin.top;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) {
locFinalPosY -= locRelativeWidgetMargin.bottom;
}
locFinalPosX += locMargin.left;
@@ -1423,8 +1413,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosY -= locMargin.top;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) {
locFinalPosY -= locRelativeWidgetMargin.bottom;
}
break;
@@ -1432,8 +1421,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
locFinalPosY -= locMargin.top;
if (locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM
&& locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM
- && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL)
- {
+ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) {
locFinalPosY -= locRelativeWidgetMargin.bottom;
}
locFinalPosX -= locMargin.right;
@@ -1449,7 +1437,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{
}
},
_doLayout: function () {
- if(!this._doLayoutDirty){
+ if (!this._doLayoutDirty) {
return;
}
switch (this._layoutType) {
@@ -1505,12 +1493,12 @@ ccui.Layout._visit_once = null;
ccui.Layout._layer = null;
ccui.Layout._sharedCache = null;
-if(cc._renderType == cc._RENDER_TYPE_WEBGL){
+if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
//WebGL
ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForWebGL;
ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForWebGL;
ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._scissorClippingVisitForWebGL;
-}else{
+} else {
ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForCanvas;
ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas;
ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas;
@@ -1519,7 +1507,7 @@ ccui.Layout._getSharedCache = function () {
return (cc.ClippingNode._sharedCache) || (cc.ClippingNode._sharedCache = cc.newElement("canvas"));
};
-window._p = ccui.Layout.prototype;
+var _p = ccui.Layout.prototype;
// Extended properties
/** @expose */
@@ -1532,7 +1520,7 @@ cc.defineGetterSetter(_p, "clippingType", null, _p.setClippingType);
_p.layoutType;
cc.defineGetterSetter(_p, "layoutType", _p.getLayoutType, _p.setLayoutType);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UILayout.
diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js
index 97529c3601..1e878ca816 100644
--- a/extensions/ccui/uiwidgets/UIButton.js
+++ b/extensions/ccui/uiwidgets/UIButton.js
@@ -63,7 +63,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
_normalTextureLoaded: false,
_pressedTextureLoaded: false,
_disabledTextureLoaded: false,
- _className:"Button",
+ _className: "Button",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._buttonNormalRenderer = null;
@@ -97,7 +97,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
},
init: function () {
- if (ccui.Widget.prototype.init.call(this)){
+ if (ccui.Widget.prototype.init.call(this)) {
this.setTouchEnabled(true);
return true;
}
@@ -165,7 +165,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
* Get button is using scale9 renderer or not.
* @returns {Boolean}
*/
- isScale9Enabled:function(){
+ isScale9Enabled: function () {
return this._scale9Enabled;
},
@@ -202,7 +202,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
if (!normal) {
return;
}
- texType = texType||ccui.Widget.LOCAL_TEXTURE;
+ texType = texType || ccui.Widget.LOCAL_TEXTURE;
this._normalFileName = normal;
this._normalTexType = texType;
var buttonNormalRenderer = this._buttonNormalRenderer;
@@ -218,17 +218,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
}
var buttonRenderSize = buttonNormalRenderer.getContentSize();
- if(buttonNormalRenderer.textureLoaded()){
+ if (buttonNormalRenderer.textureLoaded()) {
this._normalTextureSize.width = buttonRenderSize.width;
this._normalTextureSize.height = buttonRenderSize.height;
- }else{
- buttonNormalRenderer.addLoadedEventListener(function(){
+ } else {
+ buttonNormalRenderer.addLoadedEventListener(function () {
this._normalTextureSize = buttonNormalRenderer.getContentSize();
if (buttonNormalRenderer.setCapInsets) {
buttonNormalRenderer.setCapInsets(this._capInsetsNormal);
}
this.normalTextureScaleChangedWithSize();
- },this);
+ }, this);
this._normalTextureSize.width = this._customSize.width;
this._normalTextureSize.height = this._customSize.height;
}
@@ -268,16 +268,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
break;
}
- if(clickedRenderer.textureLoaded()){
+ if (clickedRenderer.textureLoaded()) {
this._pressedTextureSize = clickedRenderer.getContentSize();
- }else{
- clickedRenderer.addLoadedEventListener(function(){
+ } else {
+ clickedRenderer.addLoadedEventListener(function () {
this._pressedTextureSize = clickedRenderer.getContentSize();
if (clickedRenderer.setCapInsets) {
clickedRenderer.setCapInsets(this._capInsetsNormal);
}
this.pressedTextureScaleChangedWithSize();
- },this);
+ }, this);
this._pressedTextureSize.width = this._customSize.width;
this._pressedTextureSize.height = this._customSize.height;
}
@@ -317,16 +317,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
break;
}
- if(disableRenderer.textureLoaded()){
+ if (disableRenderer.textureLoaded()) {
this._disabledTextureSize = disableRenderer.getContentSize();
- }else{
- disableRenderer.addLoadedEventListener(function(){
+ } else {
+ disableRenderer.addLoadedEventListener(function () {
this._disabledTextureSize = disableRenderer.getContentSize();
if (disableRenderer.setCapInsets) {
disableRenderer.setCapInsets(this._capInsetsNormal);
}
this.disabledTextureScaleChangedWithSize();
- },this);
+ }, this);
this._disabledTextureSize.width = this._customSize.width;
this._disabledTextureSize.height = this._customSize.height;
}
@@ -368,7 +368,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
* Get normal renderer cap insets .
* @returns {cc.Rect}
*/
- getCapInsetNormalRenderer:function(){
+ getCapInsetNormalRenderer: function () {
return this._capInsetsNormal;
},
@@ -388,7 +388,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
* Get pressed renderer cap insets .
* @returns {cc.Rect}
*/
- getCapInsetPressedRenderer:function(){
+ getCapInsetPressedRenderer: function () {
return this._capInsetsPressed;
},
@@ -408,7 +408,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
* Get disable renderer cap insets .
* @returns {cc.Rect}
*/
- getCapInsetDisabledRenderer:function(){
+ getCapInsetDisabledRenderer: function () {
return this._capInsetsDisabled;
},
@@ -500,7 +500,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
this._buttonClickedRenderer.setScaleY(1);
this._buttonDisableRenderer.setScaleY(1);
}
- }else{
+ } else {
this._buttonNormalRenderer.setFlippedY(this._flippedY);
this._buttonClickedRenderer.setFlippedY(this._flippedY);
this._buttonDisableRenderer.setFlippedY(this._flippedY);
@@ -513,35 +513,35 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
* @param {Number} [y] The anchor point.y of UIButton.
*/
setAnchorPoint: function (point, y) {
- if(y === undefined){
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._buttonNormalRenderer.setAnchorPoint(point);
- this._buttonClickedRenderer.setAnchorPoint(point);
- this._buttonDisableRenderer.setAnchorPoint(point);
+ if (y === undefined) {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._buttonNormalRenderer.setAnchorPoint(point);
+ this._buttonClickedRenderer.setAnchorPoint(point);
+ this._buttonDisableRenderer.setAnchorPoint(point);
} else {
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._buttonNormalRenderer.setAnchorPoint(point, y);
- this._buttonClickedRenderer.setAnchorPoint(point, y);
- this._buttonDisableRenderer.setAnchorPoint(point, y);
- }
- this._titleRenderer.setPosition(this._size.width * (0.5 - this._anchorPoint.x), this._size.height * (0.5 - this._anchorPoint.y));
- },
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._buttonNormalRenderer._setAnchorX(value);
- this._buttonClickedRenderer._setAnchorX(value);
- this._buttonDisableRenderer._setAnchorX(value);
-
- this._titleRenderer.setPositionX(this._size.width * (0.5 - this._anchorPoint.x));
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._buttonNormalRenderer._setAnchorY(value);
- this._buttonClickedRenderer._setAnchorY(value);
- this._buttonDisableRenderer._setAnchorY(value);
-
- this._titleRenderer.setPositionY(this._size.height * (0.5 - this._anchorPoint.y));
- },
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._buttonNormalRenderer.setAnchorPoint(point, y);
+ this._buttonClickedRenderer.setAnchorPoint(point, y);
+ this._buttonDisableRenderer.setAnchorPoint(point, y);
+ }
+ this._titleRenderer.setPosition(this._size.width * (0.5 - this._anchorPoint.x), this._size.height * (0.5 - this._anchorPoint.y));
+ },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._buttonNormalRenderer._setAnchorX(value);
+ this._buttonClickedRenderer._setAnchorX(value);
+ this._buttonDisableRenderer._setAnchorX(value);
+
+ this._titleRenderer.setPositionX(this._size.width * (0.5 - this._anchorPoint.x));
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._buttonNormalRenderer._setAnchorY(value);
+ this._buttonClickedRenderer._setAnchorY(value);
+ this._buttonDisableRenderer._setAnchorY(value);
+
+ this._titleRenderer.setPositionY(this._size.height * (0.5 - this._anchorPoint.y));
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -557,12 +557,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
getContentSize: function () {
return this._normalTextureSize;
},
- _getWidth: function () {
- return this._scale9Enabled ? this._size.width : this._normalTextureSize.width;
- },
- _getHeight: function () {
- return this._scale9Enabled ? this._size.height : this._normalTextureSize.height;
- },
+ _getWidth: function () {
+ return this._scale9Enabled ? this._size.width : this._normalTextureSize.width;
+ },
+ _getHeight: function () {
+ return this._scale9Enabled ? this._size.height : this._normalTextureSize.height;
+ },
/**
* Gets the Virtual Renderer of widget.
@@ -741,12 +741,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
return this._titleRenderer.getFontName();
},
- _setTitleFont: function (font) {
- this._titleRenderer.font = font;
- },
- _getTitleFont: function () {
- return this._titleRenderer.font;
- },
+ _setTitleFont: function (font) {
+ this._titleRenderer.font = font;
+ },
+ _getTitleFont: function () {
+ return this._titleRenderer.font;
+ },
updateTextureColor: function () {
this.updateColorToRenderer(this._buttonNormalRenderer);
@@ -768,11 +768,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
return "Button";
},
- createCloneInstance:function(){
+ createCloneInstance: function () {
return ccui.Button.create();
},
- copySpecialProperties:function(uiButton){
+ copySpecialProperties: function (uiButton) {
this._prevIgnoreSize = uiButton._prevIgnoreSize;
this.setScale9Enabled(uiButton._scale9Enabled);
this.loadTextureNormal(uiButton._normalFileName, uiButton._normalTexType);
@@ -790,7 +790,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{
});
-window._p = ccui.Button.prototype;
+var _p = ccui.Button.prototype;
// Extended properties
/** @expose */
@@ -809,7 +809,7 @@ cc.defineGetterSetter(_p, "titleFontName", _p.getTitleFontName, _p.setTitleFontN
_p.titleColor;
cc.defineGetterSetter(_p, "titleColor", _p.getTitleColor, _p.setTitleColor);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UIButton.
diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js
index 859adcf853..ab0eb005e6 100644
--- a/extensions/ccui/uiwidgets/UICheckBox.js
+++ b/extensions/ccui/uiwidgets/UICheckBox.js
@@ -48,7 +48,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
_frontCrossFileName: "",
_backGroundDisabledFileName: "",
_frontCrossDisabledFileName: "",
- _className:"CheckBox",
+ _className: "CheckBox",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._backGroundBoxRenderer = null;
@@ -137,11 +137,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
this.updateAnchorPoint();
this.updateFlippedX();
this.updateFlippedY();
- if(!bgBoxRenderer.textureLoaded()){
+ if (!bgBoxRenderer.textureLoaded()) {
this._backGroundBoxRenderer.setContentSize(this._customSize);
- bgBoxRenderer.addLoadedEventListener(function(){
+ bgBoxRenderer.addLoadedEventListener(function () {
this.backGroundTextureScaleChangedWithSize();
- },this);
+ }, this);
}
this.backGroundTextureScaleChangedWithSize();
},
@@ -261,7 +261,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
this.frontCrossDisabledTextureScaleChangedWithSize();
},
- onTouchEnded: function (touch , event) {
+ onTouchEnded: function (touch, event) {
var touchPoint = touch.getLocation();
this._touchEndPos.x = touchPoint.x;
this._touchEndPos.y = touchPoint.y;
@@ -278,7 +278,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
}
this.setFocused(false);
var widgetParent = this.getWidgetParent();
- if(widgetParent){
+ if (widgetParent) {
widgetParent.checkChildInfo(2, this, touchPoint);
}
},
@@ -363,38 +363,38 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
* @param {Number} [y] The anchor point.y of UICheckBox.
*/
setAnchorPoint: function (point, y) {
- if(y === undefined){
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._backGroundBoxRenderer.setAnchorPoint(point);
- this._backGroundSelectedBoxRenderer.setAnchorPoint(point);
- this._backGroundBoxDisabledRenderer.setAnchorPoint(point);
- this._frontCrossRenderer.setAnchorPoint(point);
- this._frontCrossDisabledRenderer.setAnchorPoint(point);
- }else{
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._backGroundBoxRenderer.setAnchorPoint(point, y);
- this._backGroundSelectedBoxRenderer.setAnchorPoint(point, y);
- this._backGroundBoxDisabledRenderer.setAnchorPoint(point, y);
- this._frontCrossRenderer.setAnchorPoint(point, y);
- this._frontCrossDisabledRenderer.setAnchorPoint(point, y);
+ if (y === undefined) {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._backGroundBoxRenderer.setAnchorPoint(point);
+ this._backGroundSelectedBoxRenderer.setAnchorPoint(point);
+ this._backGroundBoxDisabledRenderer.setAnchorPoint(point);
+ this._frontCrossRenderer.setAnchorPoint(point);
+ this._frontCrossDisabledRenderer.setAnchorPoint(point);
+ } else {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._backGroundBoxRenderer.setAnchorPoint(point, y);
+ this._backGroundSelectedBoxRenderer.setAnchorPoint(point, y);
+ this._backGroundBoxDisabledRenderer.setAnchorPoint(point, y);
+ this._frontCrossRenderer.setAnchorPoint(point, y);
+ this._frontCrossDisabledRenderer.setAnchorPoint(point, y);
}
},
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._backGroundBoxRenderer._setAnchorX(value);
- this._backGroundSelectedBoxRenderer._setAnchorX(value);
- this._backGroundBoxDisabledRenderer._setAnchorX(value);
- this._frontCrossRenderer._setAnchorX(value);
- this._frontCrossDisabledRenderer._setAnchorX(value);
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._backGroundBoxRenderer._setAnchorY(value);
- this._backGroundSelectedBoxRenderer._setAnchorY(value);
- this._backGroundBoxDisabledRenderer._setAnchorY(value);
- this._frontCrossRenderer._setAnchorY(value);
- this._frontCrossDisabledRenderer._setAnchorY(value);
- },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._backGroundBoxRenderer._setAnchorX(value);
+ this._backGroundSelectedBoxRenderer._setAnchorX(value);
+ this._backGroundBoxDisabledRenderer._setAnchorX(value);
+ this._frontCrossRenderer._setAnchorX(value);
+ this._frontCrossDisabledRenderer._setAnchorX(value);
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._backGroundBoxRenderer._setAnchorY(value);
+ this._backGroundSelectedBoxRenderer._setAnchorY(value);
+ this._backGroundBoxDisabledRenderer._setAnchorY(value);
+ this._frontCrossRenderer._setAnchorY(value);
+ this._frontCrossDisabledRenderer._setAnchorY(value);
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -412,12 +412,12 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
getContentSize: function () {
return this._backGroundBoxRenderer.getContentSize();
},
- _getWidth: function () {
- return this._backGroundBoxRenderer._getWidth();
- },
- _getHeight: function () {
- return this._backGroundBoxRenderer._getHeight();
- },
+ _getWidth: function () {
+ return this._backGroundBoxRenderer._getWidth();
+ },
+ _getHeight: function () {
+ return this._backGroundBoxRenderer._getHeight();
+ },
/**
* override "getVirtualRenderer" method of widget.
@@ -553,14 +553,14 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
}
});
-window._p = ccui.CheckBox.prototype;
+var _p = ccui.CheckBox.prototype;
// Extended properties
/** @expose */
_p.selected;
cc.defineGetterSetter(_p, "selected", _p.getSelectedState, _p.setSelectedState);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UICheckBox.
diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js
index e28a5bd944..73358bab9a 100644
--- a/extensions/ccui/uiwidgets/UILoadingBar.js
+++ b/extensions/ccui/uiwidgets/UILoadingBar.js
@@ -42,7 +42,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
_capInsets: null,
_textureFile: "",
_isTextureLoaded: false,
- _className:"LoadingBar",
+ _className: "LoadingBar",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._barType = ccui.LoadingBar.TYPE_LEFT;
@@ -116,7 +116,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
var barRenderer = this._barRenderer;
switch (this._renderBarTexType) {
case ccui.Widget.LOCAL_TEXTURE:
- if(this._scale9Enabled)
+ if (this._scale9Enabled)
barRenderer.initWithFile(texture);
else
barRenderer.init(texture);
@@ -127,7 +127,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
default:
break;
}
- if (this._scale9Enabled){
+ if (this._scale9Enabled) {
barRenderer.setCapInsets(this._capInsets);
}
this.updateColorToRenderer(barRenderer);
@@ -206,7 +206,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
* Get loadingBar is using scale9 renderer or not..
* @returns {Boolean}
*/
- isScale9Enabled:function(){
+ isScale9Enabled: function () {
return this._scale9Enabled;
},
@@ -226,7 +226,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
* Get cap insets for loadingBar.
* @returns {cc.Rect}
*/
- getCapInsets:function(){
+ getCapInsets: function () {
return this._capInsets;
},
@@ -242,13 +242,13 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
return;
}
this._percent = percent;
- if(!this._isTextureLoaded){
+ if (!this._isTextureLoaded) {
return;
}
var res = this._percent / 100.0;
var x = 0, y = 0;
- if(this._renderBarTexType==ccui.Widget.PLIST_TEXTURE){
+ if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) {
var barNode = this._barRenderer;
if (barNode) {
var to = barNode.getTextureRect()._origin;
@@ -293,12 +293,12 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
getContentSize: function () {
return this._barRendererTextureSize;
},
- _getWidth: function () {
- return this._barRendererTextureSize.width;
- },
- _getHeight: function () {
- return this._barRendererTextureSize.height;
- },
+ _getWidth: function () {
+ return this._barRendererTextureSize.width;
+ },
+ _getHeight: function () {
+ return this._barRendererTextureSize.height;
+ },
/**
* override "getContentSize" method of widget.
@@ -381,7 +381,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{
}
});
-window._p = ccui.LoadingBar.prototype;
+var _p = ccui.LoadingBar.prototype;
// Extended properties
/** @expose */
@@ -391,7 +391,7 @@ cc.defineGetterSetter(_p, "direction", _p.getDirection, _p.setDirection);
_p.percent;
cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UILoadingBar.
diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js
index 30778e5ff6..3563f26d47 100644
--- a/extensions/ccui/uiwidgets/UISlider.js
+++ b/extensions/ccui/uiwidgets/UISlider.js
@@ -56,7 +56,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
_ballPTexType: null,
_ballDTexType: null,
_isTextureLoaded: false,
- _className:"Slider",
+ _className: "Slider",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._barRenderer = null;
@@ -87,8 +87,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
this._isTextureLoaded = false;
},
- init:function(){
- if(ccui.Widget.prototype.init.call(this)){
+ init: function () {
+ if (ccui.Widget.prototype.init.call(this)) {
this.setTouchEnabled(true);
return true;
}
@@ -231,7 +231,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
* Get slider is using scale9 renderer or not.
* @returns {Boolean}
*/
- isScale9Enabled:function(){
+ isScale9Enabled: function () {
return this._scale9Enabled;
},
@@ -271,7 +271,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
* Get cap insets for slider.
* @returns {cc.Rect}
*/
- getCapInsetBarRenderer:function(){
+ getCapInsetBarRenderer: function () {
return this._capInsetsBarRenderer;
},
@@ -291,7 +291,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
* Get cap insets for slider.
* @returns {cc.Rect}
*/
- getCapInsetProgressBarRenderer:function(){
+ getCapInsetProgressBarRenderer: function () {
return this._capInsetsProgressBarRenderer;
},
@@ -395,7 +395,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
percent = 0;
}
this._percent = percent;
- if(!this._isTextureLoaded){
+ if (!this._isTextureLoaded) {
return;
}
var dis = this._barLength * (percent / 100.0);
@@ -417,9 +417,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
}
},
- onTouchBegan: function (touch , event) {
- var pass = ccui.Widget.prototype.onTouchBegan.call(this,touch , event);
- if(this._hitted){
+ onTouchBegan: function (touch, event) {
+ var pass = ccui.Widget.prototype.onTouchBegan.call(this, touch, event);
+ if (this._hitted) {
var nsp = this.convertToNodeSpace(this._touchStartPos);
this.setPercent(this.getPercentWithBallPos(nsp.x));
this.percentChangedEvent();
@@ -427,7 +427,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
return pass;
},
- onTouchMoved: function (touch , event) {
+ onTouchMoved: function (touch, event) {
var touchPoint = touch.getLocation();
this._touchMovePos.x = touchPoint.x;
this._touchMovePos.y = touchPoint.y;
@@ -437,12 +437,12 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
this.percentChangedEvent();
},
- onTouchEnded: function (touch , event) {
- ccui.Widget.prototype.onTouchEnded.call(this, touch , event);
+ onTouchEnded: function (touch, event) {
+ ccui.Widget.prototype.onTouchEnded.call(this, touch, event);
},
- onTouchCancelled: function (touch , event) {
- ccui.Widget.prototype.onTouchCancelled.call(this, touch , event);
+ onTouchCancelled: function (touch, event) {
+ ccui.Widget.prototype.onTouchCancelled.call(this, touch, event);
},
/**
@@ -490,14 +490,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
*/
getContentSize: function () {
var locContentSize = this._barRenderer.getContentSize();
- return cc.size(locContentSize.width,locContentSize.height);
+ return cc.size(locContentSize.width, locContentSize.height);
+ },
+ _getWidth: function () {
+ return this._barRenderer._getWidth();
+ },
+ _getHeight: function () {
+ return this._barRenderer._getHeight();
},
- _getWidth: function () {
- return this._barRenderer._getWidth();
- },
- _getHeight: function () {
- return this._barRenderer._getHeight();
- },
/**
* override "getContentSize" method of widget.
@@ -518,7 +518,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
else {
this._barLength = this._size.width;
if (this._scale9Enabled) {
- this._barRenderer.setPreferredSize(cc.size(this._size.width,this._size.height));
+ this._barRenderer.setPreferredSize(cc.size(this._size.width, this._size.height));
}
else {
var btextureSize = this._barRenderer.getContentSize();
@@ -547,7 +547,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
}
else {
if (this._scale9Enabled) {
- this._progressBarRenderer.setPreferredSize(cc.size(this._size.width,this._size.height));
+ this._progressBarRenderer.setPreferredSize(cc.size(this._size.width, this._size.height));
}
else {
var ptextureSize = this._progressBarTextureSize;
@@ -623,14 +623,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{
}
});
-window._p = ccui.Slider.prototype;
+var _p = ccui.Slider.prototype;
// Extended properties
/** @expose */
_p.percent;
cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UISlider.
diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js
index 7ffa1b2c41..24b98b50ec 100644
--- a/extensions/ccui/uiwidgets/UIText.js
+++ b/extensions/ccui/uiwidgets/UIText.js
@@ -46,10 +46,10 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
_fontSize: 0,
_onSelectedScaleOffset: 0,
_labelRenderer: "",
- _textAreaSize:null,
- _textVerticalAlignment:0,
- _textHorizontalAlignment:0,
- _className:"Text",
+ _textAreaSize: null,
+ _textVerticalAlignment: 0,
+ _textHorizontalAlignment: 0,
+ _className: "Text",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this.touchScaleEnabled = false;
@@ -77,7 +77,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
},
/**
- * Changes the string value of label.
+ * Changes the value of label.
* @param {String} text
*/
setText: function (text) {
@@ -116,7 +116,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
* Get font Size
* @returns {Number}
*/
- getFontSize:function(){
+ getFontSize: function () {
return this._fontSize;
},
@@ -134,22 +134,22 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
* Get font name
* @returns {string}
*/
- getFontName:function(){
+ getFontName: function () {
return this._fontName;
},
- _setFont: function (font) {
- var res = cc.LabelTTF._fontStyleRE.exec(font);
- if(res) {
- this._fontSize = parseInt(res[1]);
- this._fontName = res[2];
- this._labelRenderer._setFont(font);
- this.labelScaleChangedWithSize();
- }
- },
- _getFont: function () {
- return this._labelRenderer._getFont();
- },
+ _setFont: function (font) {
+ var res = cc.LabelTTF._fontStyleRE.exec(font);
+ if (res) {
+ this._fontSize = parseInt(res[1]);
+ this._fontName = res[2];
+ this._labelRenderer._setFont(font);
+ this.labelScaleChangedWithSize();
+ }
+ },
+ _getFont: function () {
+ return this._labelRenderer._getFont();
+ },
/**
* set textAreaSize
@@ -161,22 +161,22 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
this._labelRenderer.setDimensions(size);
this.labelScaleChangedWithSize();
},
- _setBoundingWidth: function (value) {
- this._textAreaSize.width = value;
- this._labelRenderer._setBoundingWidth(value);
- this.labelScaleChangedWithSize();
- },
- _setBoundingHeight: function (value) {
- this._textAreaSize.height = value;
- this._labelRenderer._setBoundingHeight(value);
- this.labelScaleChangedWithSize();
- },
- _getBoundingWidth: function () {
- return this._textAreaSize.width;
- },
- _getBoundingHeight: function () {
- return this._textAreaSize.height;
- },
+ _setBoundingWidth: function (value) {
+ this._textAreaSize.width = value;
+ this._labelRenderer._setBoundingWidth(value);
+ this.labelScaleChangedWithSize();
+ },
+ _setBoundingHeight: function (value) {
+ this._textAreaSize.height = value;
+ this._labelRenderer._setBoundingHeight(value);
+ this.labelScaleChangedWithSize();
+ },
+ _getBoundingWidth: function () {
+ return this._textAreaSize.width;
+ },
+ _getBoundingHeight: function () {
+ return this._textAreaSize.height;
+ },
/**
* set Horizontal Alignment of cc.LabelTTF
@@ -192,7 +192,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
* Return Horizontal Alignment of label
* @returns {TEXT_ALIGNMENT_LEFT|TEXT_ALIGNMENT_CENTER|TEXT_ALIGNMENT_RIGHT}
*/
- getTextHorizontalAlignment:function(){
+ getTextHorizontalAlignment: function () {
return this._textHorizontalAlignment;
},
@@ -210,7 +210,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
* Get text vertical alignment.
* @returns {VERTICAL_TEXT_ALIGNMENT_TOP|VERTICAL_TEXT_ALIGNMENT_CENTER|VERTICAL_TEXT_ALIGNMENT_BOTTOM}
*/
- getTextVerticalAlignment:function(){
+ getTextVerticalAlignment: function () {
return this._textVerticalAlignment;
},
@@ -273,22 +273,22 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
* @param {Number} [y] The anchor point.y of UILabel.
*/
setAnchorPoint: function (point, y) {
- if(y === undefined){
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._labelRenderer.setAnchorPoint(point);
+ if (y === undefined) {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._labelRenderer.setAnchorPoint(point);
} else {
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._labelRenderer.setAnchorPoint(point, y);
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._labelRenderer.setAnchorPoint(point, y);
}
},
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._labelRenderer._setAnchorX(value);
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._labelRenderer._setAnchorY(value);
- },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._labelRenderer._setAnchorX(value);
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._labelRenderer._setAnchorY(value);
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -302,12 +302,12 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
getContentSize: function () {
return this._labelRenderer.getContentSize();
},
- _getWidth: function () {
- return this._labelRenderer._getWidth();
- },
- _getHeight: function () {
- return this._labelRenderer._getHeight();
- },
+ _getWidth: function () {
+ return this._labelRenderer._getWidth();
+ },
+ _getHeight: function () {
+ return this._labelRenderer._getHeight();
+ },
/**
* override "getVirtualRenderer" method of widget.
@@ -371,7 +371,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{
}
});
-window._p = ccui.Text.prototype;
+var _p = ccui.Text.prototype;
// Extended properties
/** @expose */
@@ -402,7 +402,7 @@ cc.defineGetterSetter(_p, "textAlign", _p.getTextHorizontalAlignment, _p.setText
_p.verticalAlign;
cc.defineGetterSetter(_p, "verticalAlign", _p.getTextVerticalAlignment, _p.setTextVerticalAlignment);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UILabel.
diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js
index 9c3a557cc8..34ac176eeb 100644
--- a/extensions/ccui/uiwidgets/UITextAtlas.js
+++ b/extensions/ccui/uiwidgets/UITextAtlas.js
@@ -36,7 +36,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{
_itemWidth: 0,
_itemHeight: 0,
_startCharMap: "",
- _className:"TextAtlas",
+ _className: "TextAtlas",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._labelAtlasRenderer = null;
@@ -98,21 +98,21 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{
*/
setAnchorPoint: function (point, y) {
if (y === undefined) {
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._labelAtlasRenderer.setAnchorPoint(point);
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._labelAtlasRenderer.setAnchorPoint(point);
} else {
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._labelAtlasRenderer.setAnchorPoint(point, y);
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._labelAtlasRenderer.setAnchorPoint(point, y);
}
},
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._labelAtlasRenderer._setAnchorX(value);
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._labelAtlasRenderer._setAnchorY(value);
- },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._labelAtlasRenderer._setAnchorX(value);
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._labelAtlasRenderer._setAnchorY(value);
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -126,12 +126,12 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{
getContentSize: function () {
return this._labelAtlasRenderer.getContentSize();
},
- _getWidth: function () {
- return this._labelAtlasRenderer._getWidth();
- },
- _getHeight: function () {
- return this._labelAtlasRenderer._getHeight();
- },
+ _getWidth: function () {
+ return this._labelAtlasRenderer._getWidth();
+ },
+ _getHeight: function () {
+ return this._labelAtlasRenderer._getHeight();
+ },
/**
* override "getVirtualRenderer" method of widget.
@@ -186,14 +186,14 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{
}
});
-window._p = ccui.TextAtlas.prototype;
+var _p = ccui.TextAtlas.prototype;
// Extended properties
/** @expose */
_p.string;
cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setStringValue);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UILabelAtlas.
diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js
index 99823bc98d..1f6fd49291 100644
--- a/extensions/ccui/uiwidgets/UITextBMFont.js
+++ b/extensions/ccui/uiwidgets/UITextBMFont.js
@@ -34,7 +34,7 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{
_fileHasInit: false,
_fntFileName: "",
_stringValue: "",
- _className:"TextBMFont",
+ _className: "TextBMFont",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._labelBMFontRenderer = null;
@@ -94,22 +94,22 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{
* @param {Number} [y] The anchor point.y of UILabelBMFont.
*/
setAnchorPoint: function (point, y) {
- if(y === undefined){
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._labelBMFontRenderer.setAnchorPoint(point);
+ if (y === undefined) {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._labelBMFontRenderer.setAnchorPoint(point);
} else {
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._labelBMFontRenderer.setAnchorPoint(point, y);
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._labelBMFontRenderer.setAnchorPoint(point, y);
}
},
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._labelBMFontRenderer._setAnchorX(value);
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._labelBMFontRenderer._setAnchorY(value);
- },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._labelBMFontRenderer._setAnchorX(value);
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._labelBMFontRenderer._setAnchorY(value);
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -123,12 +123,12 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{
getContentSize: function () {
return this._labelBMFontRenderer.getContentSize();
},
- _getWidth: function () {
- return this._labelBMFontRenderer._getWidth();
- },
- _getHeight: function () {
- return this._labelBMFontRenderer._getHeight();
- },
+ _getWidth: function () {
+ return this._labelBMFontRenderer._getWidth();
+ },
+ _getHeight: function () {
+ return this._labelBMFontRenderer._getHeight();
+ },
/**
* override "getVirtualRenderer" method of widget.
@@ -184,14 +184,14 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{
}
});
-window._p = ccui.TextBMFont.prototype;
+var _p = ccui.TextBMFont.prototype;
// Extended properties
/** @expose */
_p.string;
cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setStringValue);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UILabelBMFont.
diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js
index 711e371c48..0b7e74d3a5 100644
--- a/extensions/ccui/uiwidgets/UITextField.js
+++ b/extensions/ccui/uiwidgets/UITextField.js
@@ -40,7 +40,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{
_detachWithIME: false,
_insertText: false,
_deleteBackward: false,
- _className:"UICCTextField",
+ _className: "UICCTextField",
ctor: function () {
cc.TextFieldTTF.prototype.ctor.call(this);
this.maxLengthEnabled = false;
@@ -52,8 +52,8 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{
this._insertText = false;
this._deleteBackward = false;
},
- init:function(){
- if(ccui.Widget.prototype.init.call(this)){
+ init: function () {
+ if (ccui.Widget.prototype.init.call(this)) {
this.setTouchEnabled(true);
return true;
}
@@ -61,7 +61,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{
},
onEnter: function () {
cc.TextFieldTTF.prototype.onEnter.call(this);
- cc.TextFieldTTF.prototype.setDelegate.call(this,this);
+ cc.TextFieldTTF.prototype.setDelegate.call(this, this);
},
//CCTextFieldDelegate
@@ -114,7 +114,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{
}
}
}
- cc.TextFieldTTF.prototype.insertText.call(this,str_text, len);
+ cc.TextFieldTTF.prototype.insertText.call(this, str_text, len);
// password
if (this.passwordEnabled) {
@@ -142,7 +142,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{
closeIME: function () {
cc.TextFieldTTF.prototype.detachWithIME.call(this);
},
- onDraw:function (sender) {
+ onDraw: function (sender) {
return false;
},
setMaxLengthEnabled: function (enable) {
@@ -265,7 +265,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
_detachWithIMESelector: null,
_insertTextSelector: null,
_deleteBackwardSelector: null,
- _passwordStyleText:"",
+ _passwordStyleText: "",
ctor: function () {
ccui.Widget.prototype.ctor.call(this);
this._textFieldRender = null;
@@ -285,7 +285,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
this._deleteBackwardSelector = null;
},
- onEnter:function(){
+ onEnter: function () {
ccui.Widget.prototype.onEnter.call(this);
this.setUpdateEnabled(true);
},
@@ -310,8 +310,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
* Get touch size.
* @returns {cc.Size}
*/
- getTouchSize:function(){
- return cc.size(this._touchWidth,this._touchHeight);
+ getTouchSize: function () {
+ return cc.size(this._touchWidth, this._touchHeight);
},
/**
@@ -348,18 +348,18 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
/**
* @returns {String}
*/
- getPlaceHolder:function(){
+ getPlaceHolder: function () {
return this._textFieldRender.getPlaceHolder();
},
- _setFont: function (font) {
- this._textFieldRender._setFont(font);
- this.textfieldRendererScaleChangedWithSize();
- },
+ _setFont: function (font) {
+ this._textFieldRender._setFont(font);
+ this.textfieldRendererScaleChangedWithSize();
+ },
- _getFont: function () {
- return this._textFieldRender._getFont();
- },
+ _getFont: function () {
+ return this._textFieldRender._getFont();
+ },
/**
* Set font size for text field content
@@ -370,13 +370,13 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
this.textfieldRendererScaleChangedWithSize();
},
- /**
- * Get font size for text field content
- * @param {cc.Size} size
- */
- getFontSize: function () {
- return this._textFieldRender.getFontSize();
- },
+ /**
+ * Get font size for text field content
+ * @param {cc.Size} size
+ */
+ getFontSize: function () {
+ return this._textFieldRender.getFontSize();
+ },
/**
* Set font name for text field content
@@ -387,13 +387,13 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
this.textfieldRendererScaleChangedWithSize();
},
- /**
- * Get font name for text field content
- * @param {cc.Size} size
- */
- getFontName: function () {
- return this._textFieldRender.getFontName();
- },
+ /**
+ * Get font name for text field content
+ * @param {cc.Size} size
+ */
+ getFontName: function () {
+ return this._textFieldRender.getFontName();
+ },
/**
* detach with IME
@@ -481,7 +481,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
/**
* @returns {String}
*/
- getPasswordStyleText:function(){
+ getPasswordStyleText: function () {
return this._passwordStyleText;
},
@@ -623,22 +623,22 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
* @param {Number} [y] The anchor point.y of UILabelBMFont.
*/
setAnchorPoint: function (point, y) {
- if(y === undefined){
- ccui.Widget.prototype.setAnchorPoint.call(this, point);
- this._textFieldRender.setAnchorPoint(point);
+ if (y === undefined) {
+ ccui.Widget.prototype.setAnchorPoint.call(this, point);
+ this._textFieldRender.setAnchorPoint(point);
} else {
- ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
- this._textFieldRender.setAnchorPoint(point, y);
+ ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
+ this._textFieldRender.setAnchorPoint(point, y);
}
},
- _setAnchorX: function (value) {
- ccui.Widget.prototype._setAnchorX.call(this, value);
- this._textFieldRender._setAnchorX(value);
- },
- _setAnchorY: function (value) {
- ccui.Widget.prototype._setAnchorY.call(this, value);
- this._textFieldRender._setAnchorY(value);
- },
+ _setAnchorX: function (value) {
+ ccui.Widget.prototype._setAnchorX.call(this, value);
+ this._textFieldRender._setAnchorX(value);
+ },
+ _setAnchorY: function (value) {
+ ccui.Widget.prototype._setAnchorY.call(this, value);
+ this._textFieldRender._setAnchorY(value);
+ },
onSizeChanged: function () {
ccui.Widget.prototype.onSizeChanged.call(this);
@@ -672,12 +672,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
getContentSize: function () {
return this._textFieldRender.getContentSize();
},
- _getWidth: function () {
- return this._textFieldRender._getWidth();
- },
- _getHeight: function () {
- return this._textFieldRender._getHeight();
- },
+ _getWidth: function () {
+ return this._textFieldRender._getWidth();
+ },
+ _getHeight: function () {
+ return this._textFieldRender._getHeight();
+ },
/**
* override "getContentSize" method of widget.
@@ -727,7 +727,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{
}
});
-window._p = ccui.TextField.prototype;
+var _p = ccui.TextField.prototype;
// Extended properties
/** @expose */
@@ -755,7 +755,7 @@ cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength);
_p.passwordEnabled;
cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UITextField.
diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js
index 293dbe3873..0c0ef0d978 100644
--- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js
+++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js
@@ -71,7 +71,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
inertiaScrollEnabled: false,
_scrollViewEventListener: null,
_scrollViewEventSelector: null,
- _className:"ScrollView",
+ _className: "ScrollView",
ctor: function () {
ccui.Layout.prototype.ctor.call(this);
this._innerContainer = null;
@@ -123,7 +123,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
return false;
},
- onEnter:function(){
+ onEnter: function () {
ccui.Layout.prototype.onEnter.call(this);
this.setUpdateEnabled(true);
},
@@ -214,72 +214,72 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
innerContainer.setPosition(innerPos.x, locSize.height - (1.0 - innerAP.y) * innerSize.height);
}
},
- _setInnerWidth: function (width) {
- var locW = this._size.width,
- innerWidth = locW,
- container = this._innerContainer,
- oldInnerWidth = container.width;
- if (width < locW)
- cc.log("Inner width <= scrollview width, it will be force sized!");
- else
- innerWidth = width;
- container.width = innerWidth;
-
- switch (this.direction) {
- case ccui.ScrollView.DIR_HORIZONTAL:
- case ccui.ScrollView.DIR_BOTH:
- if (container.getRightInParent() <= locW) {
- var newInnerWidth = container.width;
- var offset = oldInnerWidth - newInnerWidth;
- this.scrollChildren(offset, 0);
- }
- break;
- }
- var innerAX = container.anchorX;
- if (container.getLeftInParent() > 0.0) {
- container.x = innerAX * innerWidth;
- }
- if (container.getRightInParent() < locW) {
- container.x = locW - ((1.0 - innerAX) * innerWidth);
- }
- },
- _setInnerHeight: function (height) {
- var locH = this._size.height,
- innerHeight = locH,
- container = this._innerContainer,
- oldInnerHeight = container.height;
- if (height < locH)
- cc.log("Inner height <= scrollview height, it will be force sized!");
- else
- innerHeight = height;
- container.height = innerHeight;
-
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- case ccui.ScrollView.DIR_BOTH:
- var newInnerHeight = innerHeight;
- var offset = oldInnerHeight - newInnerHeight;
- this.scrollChildren(0, offset);
- break;
- }
- var innerAY = container.anchorY;
- if (container.getLeftInParent() > 0.0) {
- container.y = innerAY * innerHeight;
- }
- if (container.getRightInParent() < locH) {
- container.y = locH - ((1.0 - innerAY) * innerHeight);
- }
- },
+ _setInnerWidth: function (width) {
+ var locW = this._size.width,
+ innerWidth = locW,
+ container = this._innerContainer,
+ oldInnerWidth = container.width;
+ if (width < locW)
+ cc.log("Inner width <= scrollview width, it will be force sized!");
+ else
+ innerWidth = width;
+ container.width = innerWidth;
+
+ switch (this.direction) {
+ case ccui.ScrollView.DIR_HORIZONTAL:
+ case ccui.ScrollView.DIR_BOTH:
+ if (container.getRightInParent() <= locW) {
+ var newInnerWidth = container.width;
+ var offset = oldInnerWidth - newInnerWidth;
+ this.scrollChildren(offset, 0);
+ }
+ break;
+ }
+ var innerAX = container.anchorX;
+ if (container.getLeftInParent() > 0.0) {
+ container.x = innerAX * innerWidth;
+ }
+ if (container.getRightInParent() < locW) {
+ container.x = locW - ((1.0 - innerAX) * innerWidth);
+ }
+ },
+ _setInnerHeight: function (height) {
+ var locH = this._size.height,
+ innerHeight = locH,
+ container = this._innerContainer,
+ oldInnerHeight = container.height;
+ if (height < locH)
+ cc.log("Inner height <= scrollview height, it will be force sized!");
+ else
+ innerHeight = height;
+ container.height = innerHeight;
+
+ switch (this.direction) {
+ case ccui.ScrollView.DIR_VERTICAL:
+ case ccui.ScrollView.DIR_BOTH:
+ var newInnerHeight = innerHeight;
+ var offset = oldInnerHeight - newInnerHeight;
+ this.scrollChildren(0, offset);
+ break;
+ }
+ var innerAY = container.anchorY;
+ if (container.getLeftInParent() > 0.0) {
+ container.y = innerAY * innerHeight;
+ }
+ if (container.getRightInParent() < locH) {
+ container.y = locH - ((1.0 - innerAY) * innerHeight);
+ }
+ },
getInnerContainerSize: function () {
return this._innerContainer.getSize();
},
- _getInnerWidth: function () {
- return this._innerContainer.width;
- },
- _getInnerHeight: function () {
- return this._innerContainer.height;
- },
+ _getInnerWidth: function () {
+ return this._innerContainer.width;
+ },
+ _getInnerHeight: function () {
+ return this._innerContainer.height;
+ },
/**
* Add widget
@@ -303,7 +303,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
* @returns {boolean}
*/
removeChild: function (child, cleanup) {
- return this._innerContainer.removeChild(child,cleanup);
+ return this._innerContainer.removeChild(child, cleanup);
},
/**
@@ -584,10 +584,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
},
jumpToDestination: function (dstX, dstY) {
- if(dstX.x !== undefined) {
- dstY = dstX.y;
- dstX = dstX.x;
- }
+ if (dstX.x !== undefined) {
+ dstY = dstX.y;
+ dstX = dstX.x;
+ }
var finalOffsetX = dstX;
var finalOffsetY = dstY;
switch (this.direction) {
@@ -1371,26 +1371,26 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
this._bePressed = false;
},
- onTouchBegan: function (touch , event) {
- var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch , event);
- if (this._hitted) {
+ onTouchBegan: function (touch, event) {
+ var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event);
+ if (this._hitted) {
this.handlePressLogic(this._touchStartPos);
}
return pass;
},
- onTouchMoved: function (touch , event) {
- ccui.Layout.prototype.onTouchMoved.call(this, touch , event);
+ onTouchMoved: function (touch, event) {
+ ccui.Layout.prototype.onTouchMoved.call(this, touch, event);
this.handleMoveLogic(this._touchMovePos);
},
- onTouchEnded: function (touch , event) {
- ccui.Layout.prototype.onTouchEnded.call(this, touch , event);
+ onTouchEnded: function (touch, event) {
+ ccui.Layout.prototype.onTouchEnded.call(this, touch, event);
this.handleReleaseLogic(this._touchEndPos);
},
- onTouchCancelled: function (touch , event) {
- ccui.Layout.prototype.onTouchCancelled.call(this, touch , event);
+ onTouchCancelled: function (touch, event) {
+ ccui.Layout.prototype.onTouchCancelled.call(this, touch, event);
},
onTouchLongClicked: function (touchPoint) {
@@ -1447,7 +1447,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
* @param {cc.Point} touchPoint
*/
checkChildInfo: function (handleState, sender, touchPoint) {
- if(this._enabled && this._touchEnabled)
+ if (this._enabled && this._touchEnabled)
this.interceptTouchEvent(handleState, sender, touchPoint);
},
@@ -1613,7 +1613,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
}
});
-window._p = ccui.ScrollView.prototype;
+var _p = ccui.ScrollView.prototype;
// Extended properties
/** @expose */
@@ -1623,7 +1623,7 @@ cc.defineGetterSetter(_p, "innerWidth", _p._getInnerWidth, _p._setInnerWidth);
_p.innerHeight;
cc.defineGetterSetter(_p, "innerHeight", _p._getInnerHeight, _p._setInnerHeight);
-delete window._p;
+_p = null;
/**
* allocates and initializes a UIScrollView.
From e2667b76426d4c62343fe7574c82da58941a73bf Mon Sep 17 00:00:00 2001
From: VisualSJ
Date: Mon, 14 Apr 2014 14:16:57 +0800
Subject: [PATCH 0010/1564] Fixed a bug that ant. Variable name changed
---
extensions/cocostudio/armature/CCArmature.js | 142 +++++++-------
extensions/cocostudio/armature/CCBone.js | 142 +++++++-------
.../armature/animation/CCArmatureAnimation.js | 118 ++++++------
.../armature/animation/CCProcessBase.js | 78 ++++----
.../cocostudio/armature/display/CCSkin.js | 40 ++--
.../armature/physics/CCColliderDetector.js | 22 +--
extensions/editbox/CCEditBox.js | 63 ++++---
extensions/gui/control-extension/CCControl.js | 82 ++++----
.../gui/control-extension/CCControlButton.js | 178 +++++++++---------
.../CCControlColourPicker.js | 4 +-
.../control-extension/CCControlHuePicker.js | 4 +-
.../CCControlPotentiometer.js | 4 +-
.../CCControlSaturationBrightnessPicker.js | 4 +-
.../gui/control-extension/CCControlSlider.js | 4 +-
.../gui/control-extension/CCControlStepper.js | 4 +-
.../gui/control-extension/CCControlSwitch.js | 4 +-
.../gui/control-extension/CCScale9Sprite.js | 4 +-
extensions/gui/scrollview/CCScrollView.js | 4 +-
extensions/gui/scrollview/CCTableView.js | 8 +-
19 files changed, 455 insertions(+), 454 deletions(-)
diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js
index 6755985872..fa4d89f893 100644
--- a/extensions/cocostudio/armature/CCArmature.js
+++ b/extensions/cocostudio/armature/CCArmature.js
@@ -37,32 +37,32 @@
* @property {ccs.ColliderFilter} colliderFilter - <@writeonly> The collider filter of the armature
*/
ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
- animation:null,
- armatureData:null,
- batchNode:null,
- name:"",
- _textureAtlas:null,
- _parentBone:null,
- _boneDic:null,
- _topBoneList:null,
- _armatureIndexDic:null,
- _offsetPoint:null,
- version:0,
- _armatureTransformDirty:true,
- _body:null,
- _textureAtlasDic:null,
- _blendFunc:null,
- _className:"Armature",
-
- /**
- * Create a armature node.
- * @constructor
- * @param {String} name
- * @param {ccs.Bone} parentBone
- * @example
- * var armature = new ccs.Armature();
- */
- ctor:function (name, parentBone) {
+ animation: null,
+ armatureData: null,
+ batchNode: null,
+ name: "",
+ _textureAtlas: null,
+ _parentBone: null,
+ _boneDic: null,
+ _topBoneList: null,
+ _armatureIndexDic: null,
+ _offsetPoint: null,
+ version: 0,
+ _armatureTransformDirty: true,
+ _body: null,
+ _textureAtlasDic: null,
+ _blendFunc: null,
+ _className: "Armature",
+
+ /**
+ * Create a armature node.
+ * @constructor
+ * @param {String} name
+ * @param {ccs.Bone} parentBone
+ * @example
+ * var armature = new ccs.Armature();
+ */
+ ctor: function (name, parentBone) {
cc.NodeRGBA.prototype.ctor.call(this);
this.animation = null;
this.armatureData = null;
@@ -80,7 +80,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
this._textureAtlasDic = null;
this._blendFunc = null;
- parentBone && ccs.Armature.prototype.init.call(this, name, parentBone);
+ parentBone && ccs.Armature.prototype.init.call(this, name, parentBone);
},
/**
@@ -89,7 +89,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {ccs.Bone} parentBone
* @return {Boolean}
*/
- init:function (name, parentBone) {
+ init: function (name, parentBone) {
cc.NodeRGBA.prototype.init.call(this);
if (parentBone) {
this._parentBone = parentBone;
@@ -161,11 +161,11 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
this.setCascadeColorEnabled(true);
return true;
},
- onEnter:function(){
+ onEnter: function () {
cc.NodeRGBA.prototype.onEnter.call(this);
this.scheduleUpdate();
},
- onExit:function(){
+ onExit: function () {
cc.NodeRGBA.prototype.onExit.call(this);
this.unscheduleUpdate();
},
@@ -174,7 +174,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {String} boneName
* @return {ccs.Bone}
*/
- createBone:function (boneName) {
+ createBone: function (boneName) {
var existedBone = this.getBone(boneName);
if (existedBone) {
return existedBone;
@@ -201,7 +201,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {ccs.Bone} bone
* @param {String} parentName
*/
- addBone:function (bone, parentName) {
+ addBone: function (bone, parentName) {
if (!bone) {
cc.log("Argument must be non-nil");
return;
@@ -233,7 +233,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {ccs.Bone} bone
* @param {Boolean} recursion
*/
- removeBone:function (bone, recursion) {
+ removeBone: function (bone, recursion) {
if (!bone) {
cc.log("bone must be added to the bone dictionary!");
return;
@@ -251,7 +251,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {String} name
* @return {ccs.Bone}
*/
- getBone:function (name) {
+ getBone: function (name) {
return this._boneDic[name];
},
@@ -260,13 +260,13 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* @param {ccs.Bone} bone
* @param {String} parentName
*/
- changeBoneParent:function (bone, parentName) {
+ changeBoneParent: function (bone, parentName) {
if (!bone) {
cc.log("bone must be added to the bone dictionary!");
return;
}
var parentBone = bone.getParentBone();
- if(parentBone){
+ if (parentBone) {
cc.arrayRemoveObject(parentBone.getChildrenBone(), bone);
bone.setParentBone(null);
}
@@ -275,8 +275,8 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
var boneParent = this._boneDic[parentName];
if (boneParent) {
boneParent.addChildBone(bone);
- cc.arrayRemoveObject(this._topBoneList,bone);
- }else{
+ cc.arrayRemoveObject(this._topBoneList, bone);
+ } else {
this._topBoneList.push(bone);
}
}
@@ -286,14 +286,14 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* Get CCArmature's bone dictionary
* @return {Object}
*/
- getBoneDic:function () {
+ getBoneDic: function () {
return this._boneDic;
},
/**
* Set contentSize and Calculate anchor point.
*/
- updateOffsetPoint:function () {
+ updateOffsetPoint: function () {
// Set contentsize and Calculate anchor point.
var rect = this.boundingBox();
this.setContentSize(rect);
@@ -305,7 +305,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
}
},
- update:function (dt) {
+ update: function (dt) {
this.animation.update(dt);
var locTopBoneList = this._topBoneList;
for (var i = 0; i < locTopBoneList.length; i++) {
@@ -317,7 +317,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
nodeToParentTransform: null,
- _nodeToParentTransformForWebGL:function () {
+ _nodeToParentTransformForWebGL: function () {
if (this._transformDirty) {
this._armatureTransformDirty = true;
// Translate values
@@ -359,13 +359,13 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
// Build Transform Matrix
// Adjusted transform calculation for rotational skew
- var t = {a:cy * scx, b:sy * scx, c:-sx * scy, d:cx * scy, tx:x, ty:y};
+ var t = {a: cy * scx, b: sy * scx, c: -sx * scy, d: cx * scy, tx: x, ty: y};
// XXX: Try to inline skew
// If skew is needed, apply skew and then anchor point
if (needsSkewMatrix) {
- t = cc.AffineTransformConcat({a:1.0, b:Math.tan(cc.degreesToRadians(this._skewY)),
- c:Math.tan(cc.degreesToRadians(this._skewX)), d:1.0, tx:0.0, ty:0.0}, t);
+ t = cc.AffineTransformConcat({a: 1.0, b: Math.tan(cc.degreesToRadians(this._skewY)),
+ c: Math.tan(cc.degreesToRadians(this._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t);
// adjust anchor point
if (apx !== 0 || apy !== 0)
@@ -382,9 +382,9 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
return this._transform;
},
- _nodeToParentTransformForCanvas:function () {
+ _nodeToParentTransformForCanvas: function () {
if (!this._transform)
- this._transform = {a:1, b:0, c:0, d:1, tx:0, ty:0};
+ this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
if (this._transformDirty) {
this._armatureTransformDirty = true;
var t = this._transform;// quick reference
@@ -461,7 +461,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
return this._transform;
},
- draw:function () {
+ draw: function () {
//cc.g_NumberOfDraws++;
},
@@ -485,7 +485,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* This boundingBox will calculate all bones' boundingBox every time
* @return {cc.rect}
*/
- boundingBox:function () {
+ boundingBox: function () {
var minx = 0, miny = 0, maxx = 0, maxy = 0;
var first = true;
var boundingBox = cc.rect(0, 0, 0, 0);
@@ -531,7 +531,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
return null;
},
- getTexureAtlasWithTexture:function(){
+ getTexureAtlasWithTexture: function () {
return null;
},
@@ -579,7 +579,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* return parent bone
* @returns {ccs.Bone}
*/
- getParentBone:function(){
+ getParentBone: function () {
return this._parentBone;
},
@@ -587,7 +587,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* armatureAnimation getter
* @return {ccs.ArmatureAnimation}
*/
- getAnimation:function () {
+ getAnimation: function () {
return this.animation;
},
@@ -595,7 +595,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* armatureAnimation setter
* @param {ccs.ArmatureAnimation} animation
*/
- setAnimation:function (animation) {
+ setAnimation: function (animation) {
this.animation = animation;
},
@@ -603,7 +603,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* armatureData getter
* @return {ccs.ArmatureData}
*/
- getArmatureData:function () {
+ getArmatureData: function () {
return this.armatureData;
},
@@ -611,19 +611,19 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* armatureData setter
* @param {ccs.ArmatureData} armatureData
*/
- setArmatureData:function (armatureData) {
+ setArmatureData: function (armatureData) {
this.armatureData = armatureData;
},
- getName:function () {
+ getName: function () {
return this.name;
},
- setName:function (name) {
+ setName: function (name) {
this.name = name;
},
- getBatchNode:function () {
+ getBatchNode: function () {
return this.batchNode;
},
- setBatchNode:function (batchNode) {
+ setBatchNode: function (batchNode) {
this.batchNode = batchNode;
},
@@ -631,7 +631,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* version getter
* @returns {Number}
*/
- getVersion:function () {
+ getVersion: function () {
return this.version;
},
@@ -639,7 +639,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* version setter
* @param {Number} version
*/
- setVersion:function (version) {
+ setVersion: function (version) {
this.version = version;
},
@@ -647,20 +647,20 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
* armatureTransformDirty getter
* @returns {Boolean}
*/
- getArmatureTransformDirty:function () {
+ getArmatureTransformDirty: function () {
return this._armatureTransformDirty;
},
- getBody:function(){
+ getBody: function () {
return this._body;
},
- setBody:function(body){
+ setBody: function (body) {
if (this._body == body)
return;
this._body = body;
this._body.data = this;
- var child,displayObject;
+ var child, displayObject;
for (var i = 0; i < this._children.length; i++) {
child = this._children[i];
if (child instanceof ccs.Bone) {
@@ -674,8 +674,8 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
}
}
},
- getShapeList:function(){
- if(this._body)
+ getShapeList: function () {
+ if (this._body)
return this._body.shapeList;
return [];
}
@@ -683,15 +683,15 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{
});
-if(cc._renderType == cc._RENDER_TYPE_WEBGL){
+if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
//WebGL
ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForWebGL;
-}else{
+} else {
//Canvas
ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForCanvas;
}
-window._p = ccs.Armature.prototype;
+var _p = ccs.Armature.prototype;
/** @expose */
_p.parentBone;
@@ -703,7 +703,7 @@ cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
_p.colliderFilter;
cc.defineGetterSetter(_p, "colliderFilter", null, _p.setColliderFilter);
-delete window._p;
+_p = null;
/**
* allocates and initializes a armature.
diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js
index 04a787286c..b150c2aa11 100644
--- a/extensions/cocostudio/armature/CCBone.js
+++ b/extensions/cocostudio/armature/CCBone.js
@@ -43,25 +43,25 @@
*
*/
ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
- _boneData:null,
- _armature:null,
- _childArmature:null,
- displayManager:null,
- ignoreMovementBoneData:false,
- _tween:null,
- _tweenData:null,
- name:"",
- _childrenBone:null,
- parentBone:null,
- boneTransformDirty:false,
- _worldTransform:null,
- _blendFunc:0,
- blendDirty:false,
- _worldInfo:null,
- _armatureParentBone:null,
- _dataVersion:0,
- _className:"Bone",
- ctor:function () {
+ _boneData: null,
+ _armature: null,
+ _childArmature: null,
+ displayManager: null,
+ ignoreMovementBoneData: false,
+ _tween: null,
+ _tweenData: null,
+ name: "",
+ _childrenBone: null,
+ parentBone: null,
+ boneTransformDirty: false,
+ _worldTransform: null,
+ _blendFunc: 0,
+ blendDirty: false,
+ _worldInfo: null,
+ _armatureParentBone: null,
+ _dataVersion: 0,
+ _className: "Bone",
+ ctor: function () {
cc.NodeRGBA.prototype.ctor.call(this);
this._boneData = null;
this._armature = null;
@@ -82,7 +82,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
/**
* release objects
*/
- release:function () {
+ release: function () {
CC_SAFE_RELEASE(this._tweenData);
for (var i = 0; i < this._childrenBone.length; i++) {
CC_SAFE_RELEASE(this._childrenBone[i]);
@@ -99,7 +99,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* @param {String} name
* @return {Boolean}
*/
- init:function (name) {
+ init: function (name) {
cc.NodeRGBA.prototype.init.call(this);
if (name) {
this.name = name;
@@ -118,7 +118,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* set the boneData
* @param {ccs.BoneData} boneData
*/
- setBoneData:function (boneData) {
+ setBoneData: function (boneData) {
if (!boneData) {
cc.log("boneData must not be null");
return;
@@ -133,7 +133,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* boneData getter
* @return {ccs.BoneData}
*/
- getBoneData:function () {
+ getBoneData: function () {
return this._boneData;
},
@@ -141,13 +141,13 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* set the armature
* @param {ccs.Armature} armature
*/
- setArmature:function (armature) {
+ setArmature: function (armature) {
this._armature = armature;
- if(armature){
+ if (armature) {
this._tween.setAnimation(this._armature.getAnimation());
this._dataVersion = this._armature.getArmatureData().dataVersion;
this._armatureParentBone = this._armature.getParentBone();
- }else{
+ } else {
this._armatureParentBone = null;
}
},
@@ -156,7 +156,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* armature getter
* @return {ccs.Armature}
*/
- getArmature:function () {
+ getArmature: function () {
return this._armature;
},
@@ -164,7 +164,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* update worldTransform
* @param dt
*/
- update:function (dt) {
+ update: function (dt) {
var locParentBone = this.parentBone;
var locArmature = this._armature;
var locTweenData = this._tweenData;
@@ -175,7 +175,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
if (locParentBone) {
this.boneTransformDirty = this.boneTransformDirty || locParentBone.isTransformDirty();
}
- if (locArmatureParentBone && !this.boneTransformDirty){
+ if (locArmatureParentBone && !this.boneTransformDirty) {
this.boneTransformDirty = locArmatureParentBone.isTransformDirty();
}
if (this.boneTransformDirty) {
@@ -240,7 +240,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
/**
* Rewrite visit ,when node draw, g_NumberOfDraws is changeless
*/
- visit:function (ctx) {
+ visit: function (ctx) {
var node = this.getDisplayManager().getDisplayRenderNode();
if (node) {
node.visit(ctx);
@@ -251,8 +251,8 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* update display color
* @param {cc.Color} color
*/
- updateDisplayedColor:function (color) {
- this._realColor = cc.color(255,255,255);
+ updateDisplayedColor: function (color) {
+ this._realColor = cc.color(255, 255, 255);
cc.NodeRGBA.prototype.updateDisplayedColor.call(this, color);
this.updateColor();
},
@@ -261,7 +261,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* update display opacity
* @param {Number} opacity
*/
- updateDisplayedOpacity:function (opacity) {
+ updateDisplayedOpacity: function (opacity) {
this._realOpacity = 255;
cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, opacity);
this.updateColor();
@@ -288,7 +288,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
/**
* update display color
*/
- updateColor:function () {
+ updateColor: function () {
var display = this.displayManager.getDisplayRenderNode();
if (display && display.RGBAProtocol) {
var locDisplayedColor = this._displayedColor;
@@ -317,7 +317,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* Add a child to this bone, and it will let this child call setParent(ccs.Bone) function to set self to it's parent
* @param {ccs.Bone} child
*/
- addChildBone:function (child) {
+ addChildBone: function (child) {
if (!child) {
cc.log("Argument must be non-nil");
return;
@@ -337,7 +337,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* @param {ccs.Bone} bone
* @param {Boolean} recursion
*/
- removeChildBone:function (bone, recursion) {
+ removeChildBone: function (bone, recursion) {
for (var i = 0; i < this._childrenBone.length; i++) {
if (this._childrenBone[i] == bone) {
if (recursion) {
@@ -357,7 +357,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* Remove itself from its parent CCBone.
* @param {Boolean} recursion
*/
- removeFromParent:function (recursion) {
+ removeFromParent: function (recursion) {
if (this.parentBone) {
this.parentBone.removeChildBone(this, recursion);
}
@@ -369,7 +369,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* It will not set the CCArmature, if you want to add the bone to a CCArmature, you should use ccs.Armature.addBone(bone, parentName).
* @param {ccs.Bone} parent the parent bone.
*/
- setParentBone:function (parent) {
+ setParentBone: function (parent) {
this.parentBone = parent;
},
@@ -377,7 +377,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* parent bone getter
* @return {ccs.Bone}
*/
- getParentBone:function () {
+ getParentBone: function () {
return this.parentBone;
},
@@ -385,9 +385,9 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* child armature setter
* @param {ccs.Armature} armature
*/
- setChildArmature:function (armature) {
+ setChildArmature: function (armature) {
if (this._childArmature != armature) {
- if (armature == null && this._childArmature) {
+ if (armature == null && this._childArmature) {
this._childArmature.setParentBone(null);
}
this._childArmature = armature;
@@ -398,7 +398,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* child armature getter
* @return {ccs.Armature}
*/
- getChildArmature:function () {
+ getChildArmature: function () {
return this._childArmature;
},
@@ -406,7 +406,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* child bone getter
* @return {Array}
*/
- getChildrenBone:function () {
+ getChildrenBone: function () {
return this._childrenBone;
},
@@ -414,15 +414,15 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* tween getter
* @return {ccs.Tween}
*/
- getTween:function () {
+ getTween: function () {
return this._tween;
},
/**
* zOrder setter
* @param {Number}
- */
- setLocalZOrder:function (zOrder) {
+ */
+ setLocalZOrder: function (zOrder) {
if (this._zOrder != zOrder)
cc.Node.prototype.setLocalZOrder.call(this, zOrder);
},
@@ -430,8 +430,8 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
/**
* transform dirty setter
* @param {Boolean}
- */
- setTransformDirty:function (dirty) {
+ */
+ setTransformDirty: function (dirty) {
this.boneTransformDirty = dirty;
},
@@ -439,7 +439,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* transform dirty getter
* @return {Boolean}
*/
- isTransformDirty:function () {
+ isTransformDirty: function () {
return this.boneTransformDirty;
},
@@ -447,7 +447,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* return world transform
* @return {{a:0.b:0,c:0,d:0,tx:0,ty:0}}
*/
- nodeToArmatureTransform:function () {
+ nodeToArmatureTransform: function () {
return this._worldTransform;
},
@@ -484,7 +484,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
*@param {Number} index the index of the display you want to replace or add to
* -1 : append display from back
*/
- addDisplay:function (displayData, index) {
+ addDisplay: function (displayData, index) {
index = index || 0;
return this.displayManager.addDisplay(displayData, index);
},
@@ -497,8 +497,8 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
this.displayManager.removeDisplay(index);
},
- addSkin:function (skin, index) {
- index = index||0;
+ addSkin: function (skin, index) {
+ index = index || 0;
return this.displayManager.addSkin(skin, index);
},
@@ -507,7 +507,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* @param {Number} index
* @param {Boolean} force
*/
- changeDisplayByIndex:function (index, force) {
+ changeDisplayByIndex: function (index, force) {
cc.log("changeDisplayByIndex is deprecated. Use changeDisplayWithIndex instead.");
this.changeDisplayWithIndex(index, force);
},
@@ -517,7 +517,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* @param {Number} index
* @param {Boolean} force
*/
- changeDisplayWithIndex:function (index, force) {
+ changeDisplayWithIndex: function (index, force) {
this.displayManager.changeDisplayWithIndex(index, force);
},
@@ -526,7 +526,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* @param {String} name
* @param {Boolean} force
*/
- changeDisplayWithName:function (name, force) {
+ changeDisplayWithName: function (name, force) {
this.displayManager.changeDisplayWithName(name, force);
},
@@ -579,8 +579,8 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
/**
* displayManager setter
* @param {ccs.DisplayManager}
- */
- setDisplayManager:function (displayManager) {
+ */
+ setDisplayManager: function (displayManager) {
this.displayManager = displayManager;
},
@@ -588,7 +588,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* displayManager dirty getter
* @return {ccs.DisplayManager}
*/
- getDisplayManager:function () {
+ getDisplayManager: function () {
return this.displayManager;
},
@@ -597,7 +597,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* Set IgnoreMovementBoneData to true, then this bone will also show.
* @param {Boolean} bool
*/
- setIgnoreMovementBoneData:function (bool) {
+ setIgnoreMovementBoneData: function (bool) {
this.ignoreMovementBoneData = bool;
},
@@ -605,7 +605,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* ignoreMovementBoneData getter
* @return {Boolean}
*/
- getIgnoreMovementBoneData:function () {
+ getIgnoreMovementBoneData: function () {
return this.ignoreMovementBoneData;
},
@@ -613,7 +613,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* tweenData getter
* @return {ccs.FrameData}
*/
- getTweenData:function () {
+ getTweenData: function () {
return this._tweenData;
},
@@ -621,7 +621,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* name setter
* @param {String} name
*/
- setName:function (name) {
+ setName: function (name) {
this.name = name;
},
@@ -629,7 +629,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* name getter
* @return {String}
*/
- getName:function () {
+ getName: function () {
return this.name;
},
@@ -637,8 +637,8 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* BlendFunc setter
* @param {cc.BlendFunc} blendFunc
*/
- setBlendFunc:function (blendFunc) {
- if (this._blendFunc.src != blendFunc.src || this._blendFunc.dst != blendFunc.dst) {
+ setBlendFunc: function (blendFunc) {
+ if (this._blendFunc.src != blendFunc.src || this._blendFunc.dst != blendFunc.dst) {
this._blendFunc = blendFunc;
this.blendDirty = true;
}
@@ -648,20 +648,20 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{
* blendType getter
* @return {cc.BlendFunc}
*/
- getBlendFunc:function () {
+ getBlendFunc: function () {
return this._blendFunc;
},
- setBlendDirty:function(dirty){
+ setBlendDirty: function (dirty) {
this.blendDirty = dirty;
},
- isBlendDirty:function(){
+ isBlendDirty: function () {
return this.blendDirty;
}
});
-window._p = ccs.Bone.prototype;
+var _p = ccs.Bone.prototype;
// Extended properties
/** @expose */
@@ -686,7 +686,7 @@ cc.defineGetterSetter(_p, "tweenData", _p.getTweenData);
_p.colliderFilter;
cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setColliderFilter);
-delete window._p;
+_p = null;
/**
* allocates and initializes a bone.
diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js
index cbc9ab9086..60385d8da1 100644
--- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js
+++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js
@@ -37,20 +37,20 @@ ccs.MovementEventType = {
* @extends ccs.Class
*/
ccs.AnimationEvent = ccs.Class.extend(/** @lends ccs.AnimationEvent# */{
- _arguments:null,
- _callFunc:null,
- _selectorTarget:null,
- ctor:function (target, callFunc, data) {
+ _arguments: null,
+ _callFunc: null,
+ _selectorTarget: null,
+ ctor: function (target, callFunc, data) {
this._data = data;
this._callFunc = callFunc;
this._selectorTarget = target;
},
- call:function () {
+ call: function () {
if (this._callFunc) {
this._callFunc.apply(this._selectorTarget, this._arguments);
}
},
- setArguments:function (args) {
+ setArguments: function (args) {
this._arguments = args;
}
});
@@ -77,34 +77,34 @@ ccs.FrameEvent = function () {
* Base class for ccs.ArmatureAnimation objects.
* @class
* @extends ccs.ProcessBase
- *
+ *
* @property {ccs.AnimationData} animationData - Animation data
* @property {Object} userObject - User custom object
* @property {Boolean} ignoreFrameEvent - Indicate whether the frame event is ignored
* @property {Number} speedScale - Animation play speed scale
* @property {Number} animationScale - Animation play speed scale
- *
+ *
*/
ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */{
- animationData:null,
- _movementData:null,
- _armature:null,
- _movementID:"",
- _prevFrameIndex:0,
- _toIndex:0,
- _tweenList:null,
- _frameEvent:null,
- _movementEvent:null,
- _speedScale:1,
- ignoreFrameEvent:false,
- _frameEventQueue:null,
- _movementEventQueue:null,
- userObject:null,
+ animationData: null,
+ _movementData: null,
+ _armature: null,
+ _movementID: "",
+ _prevFrameIndex: 0,
+ _toIndex: 0,
+ _tweenList: null,
+ _frameEvent: null,
+ _movementEvent: null,
+ _speedScale: 1,
+ ignoreFrameEvent: false,
+ _frameEventQueue: null,
+ _movementEventQueue: null,
+ userObject: null,
_movementList: null,
_onMovementList: false,
_movementListLoop: false,
_movementIndex: 0,
- ctor:function () {
+ ctor: function () {
ccs.ProcessBase.prototype.ctor.call(this);
this.animationData = null;
this._movementData = null;
@@ -131,25 +131,25 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {ccs.Armature} armature
* @return {Boolean}
*/
- init:function (armature) {
+ init: function (armature) {
this._armature = armature;
this._tweenList = [];
return true;
},
- pause:function () {
+ pause: function () {
for (var i = 0; i < this._tweenList.length; i++) {
this._tweenList[i].pause();
}
ccs.ProcessBase.prototype.pause.call(this);
},
- resume:function () {
+ resume: function () {
for (var i = 0; i < this._tweenList.length; i++) {
this._tweenList[i].resume();
}
ccs.ProcessBase.prototype.resume.call(this);
},
- stop:function () {
+ stop: function () {
for (var i = 0; i < this._tweenList.length; i++) {
this._tweenList[i].stop();
}
@@ -161,7 +161,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* scale animation play speed
* @param {Number} speedScale
*/
- setSpeedScale:function (speedScale) {
+ setSpeedScale: function (speedScale) {
if (speedScale == this._speedScale) {
return;
}
@@ -177,14 +177,14 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
}
},
- getSpeedScale:function(){
+ getSpeedScale: function () {
return this._speedScale;
},
- getAnimationScale:function(){
+ getAnimationScale: function () {
return this.getSpeedScale();
},
- setAnimationScale:function(animationScale){
+ setAnimationScale: function (animationScale) {
return this.setSpeedScale(animationScale);
},
@@ -204,7 +204,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* armature.getAnimation().play("run",-1,1);//loop play
* armature.getAnimation().play("run",-1,0);//not loop play
*/
- play:function (animationName, durationTo, loop) {
+ play: function (animationName, durationTo, loop) {
if (this.animationData == null) {
cc.log("this.animationData can not be null");
return;
@@ -305,7 +305,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
if (this._onMovementList) {
if (this._movementListLoop) {
var movementObj = this._movementList[this._movementIndex];
- this.play(movementObj.name, movementObj.durationTo,-1,0);
+ this.play(movementObj.name, movementObj.durationTo, -1, 0);
this._movementIndex++;
if (this._movementIndex >= this._movementList.length) {
this._movementIndex = 0;
@@ -314,7 +314,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
else {
if (this._movementIndex < this._movementList.length) {
var movementObj = this._movementList[this._movementIndex];
- this.play(movementObj.name, movementObj.durationTo,-1,0);
+ this.play(movementObj.name, movementObj.durationTo, -1, 0);
this._movementIndex++;
}
else {
@@ -324,7 +324,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
this._onMovementList = true;
}
},
-
+
/**
* Go to specified frame and play current movement.
* You need first switch to the movement you want to play, then call this function.
@@ -376,7 +376,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {Number} loop
* @param {Number} tweenEasing
*/
- playWithIndex:function (animationIndex, durationTo, durationTween, loop, tweenEasing) {
+ playWithIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) {
if (typeof durationTo == "undefined") {
durationTo = -1;
}
@@ -388,7 +388,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
return;
}
var animationName = moveNames[animationIndex];
- this.play(animationName, durationTo,-1, loop, 0);
+ this.play(animationName, durationTo, -1, loop, 0);
},
/**
@@ -399,7 +399,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {Number} loop
* @param {Number} tweenEasing
*/
- playByIndex:function(animationIndex, durationTo, durationTween, loop, tweenEasing){
+ playByIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) {
cc.log("playByIndex is deprecated. Use playWithIndex instead.");
this.playWithIndex(animationIndex, durationTo, durationTween, loop, tweenEasing);
},
@@ -430,12 +430,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* get movement count
* @return {Number}
*/
- getMovementCount:function () {
+ getMovementCount: function () {
return this.animationData.getMovementCount();
},
- update:function (dt) {
- if(ccs.ProcessBase.prototype.update.call(this, dt)){
+ update: function (dt) {
+ if (ccs.ProcessBase.prototype.update.call(this, dt)) {
for (var i = 0; i < this._tweenList.length; i++) {
this._tweenList[i].update(dt);
}
@@ -459,7 +459,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
/**
* update will call this handler, you can handle your logic here
*/
- updateHandler:function () {
+ updateHandler: function () {
var locCurrentPercent = this._currentPercent;
if (locCurrentPercent >= 1) {
switch (this._loopType) {
@@ -513,7 +513,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {Object} target
* @param {function} callFunc
*/
- setMovementEventCallFunc:function (callFunc, target) {
+ setMovementEventCallFunc: function (callFunc, target) {
this._movementEvent = new ccs.AnimationEvent(target, callFunc);
},
@@ -521,7 +521,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* call event
* @param {Array} args
*/
- callMovementEvent:function (args) {
+ callMovementEvent: function (args) {
if (this._movementEvent) {
this._movementEvent.setArguments(args);
this._movementEvent.call();
@@ -533,7 +533,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {Object} target
* @param {function} callFunc
*/
- setFrameEventCallFunc:function (callFunc, target) {
+ setFrameEventCallFunc: function (callFunc, target) {
this._frameEvent = new ccs.AnimationEvent(target, callFunc);
},
@@ -541,15 +541,15 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* call event
* @param {Array} args
*/
- callFrameEvent:function (args) {
+ callFrameEvent: function (args) {
if (this._frameEvent) {
this._frameEvent.setArguments(args);
this._frameEvent.call();
}
},
- movementEvent:function(armature, movementType, movementID){
- if (this._movementEvent) {
+ movementEvent: function (armature, movementType, movementID) {
+ if (this._movementEvent) {
var event = new ccs.MovementEvent();
event.armature = armature;
event.movementType = movementType;
@@ -564,8 +564,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* @param {Number} originFrameIndex
* @param {Number} currentFrameIndex
*/
- frameEvent:function(bone, frameEventName, originFrameIndex, currentFrameIndex){
- if (this._frameEvent) {
+ frameEvent: function (bone, frameEventName, originFrameIndex, currentFrameIndex) {
+ if (this._frameEvent) {
var frameEvent = new ccs.FrameEvent();
frameEvent.bone = bone;
frameEvent.frameEventName = frameEventName;
@@ -574,12 +574,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
this._frameEventQueue.push(frameEvent);
}
},
-
+
/**
* animationData setter
* @param {ccs.AnimationData} aniData
*/
- setAnimationData:function (aniData) {
+ setAnimationData: function (aniData) {
this.animationData = aniData;
},
@@ -587,14 +587,14 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* animationData getter
* @return {ccs.AnimationData}
*/
- getAnimationData:function () {
+ getAnimationData: function () {
return this.animationData;
},
/**
* userObject setter
* @param {Object} userObject
*/
- setUserObject:function (userObject) {
+ setUserObject: function (userObject) {
this.userObject = userObject;
},
@@ -602,7 +602,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* userObject getter
* @return {Object}
*/
- getUserObject:function () {
+ getUserObject: function () {
return this.userObject;
},
@@ -610,7 +610,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* Determines if the frame event is ignored
* @returns {boolean}
*/
- isIgnoreFrameEvent:function(){
+ isIgnoreFrameEvent: function () {
return this.ignoreFrameEvent;
},
@@ -618,12 +618,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation#
* Sets whether the frame event is ignored
* @param {Boolean} bool
*/
- setIgnoreFrameEvent:function(bool){
+ setIgnoreFrameEvent: function (bool) {
this.ignoreFrameEvent = bool;
}
});
-window._p = ccs.ArmatureAnimation.prototype;
+var _p = ccs.ArmatureAnimation.prototype;
// Extended properties
/** @expose */
@@ -633,7 +633,7 @@ cc.defineGetterSetter(_p, "speedScale", _p.getSpeedScale, _p.setSpeedScale);
_p.animationScale;
cc.defineGetterSetter(_p, "animationScale", _p.getAnimationScale, _p.setAnimationScale);
-delete window._p;
+_p = null;
/**
* allocates and initializes a ArmatureAnimation.
diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js
index c63f1b7ab7..5166acc62f 100644
--- a/extensions/cocostudio/armature/animation/CCProcessBase.js
+++ b/extensions/cocostudio/armature/animation/CCProcessBase.js
@@ -84,21 +84,21 @@ ccs.ANIMATION_TYPE_MAX = 2;
* @property {Boolean} playing - <@readonly> Indicate whether the process is playing
*/
ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
- processScale:1,
- _isComplete:true,
- _isPause:true,
- _isPlaying:false,
- _currentPercent:0.0,
- _rawDuration:0,
- _loopType:0,
- _tweenEasing:0,
- animationInternal:null,
- _currentFrame:0,
- _durationTween:0,
- _nextFrameIndex:0,
- _curFrameIndex:null,
- _isLoopBack:false,
- ctor:function () {
+ processScale: 1,
+ _isComplete: true,
+ _isPause: true,
+ _isPlaying: false,
+ _currentPercent: 0.0,
+ _rawDuration: 0,
+ _loopType: 0,
+ _tweenEasing: 0,
+ animationInternal: null,
+ _currentFrame: 0,
+ _durationTween: 0,
+ _nextFrameIndex: 0,
+ _curFrameIndex: null,
+ _isLoopBack: false,
+ ctor: function () {
this.processScale = 1;
this._isComplete = true;
this._isPause = true;
@@ -109,7 +109,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
this._rawDuration = 0;
this._loopType = ccs.ANIMATION_TYPE_LOOP_BACK;
this._tweenEasing = ccs.TweenType.linear;
- this.animationInternal = 1/60;
+ this.animationInternal = 1 / 60;
this._curFrameIndex = 0;
this._durationTween = 0;
this._isLoopBack = false;
@@ -118,7 +118,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
/**
* Pause the Process
*/
- pause:function () {
+ pause: function () {
this._isPause = true;
this._isPlaying = false;
},
@@ -126,7 +126,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
/**
* Resume the Process
*/
- resume:function () {
+ resume: function () {
this._isPause = false;
this._isPlaying = true;
},
@@ -134,7 +134,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
/**
* Stop the Process
*/
- stop:function () {
+ stop: function () {
this._isComplete = true;
this._isPlaying = false;
},
@@ -144,7 +144,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* @param {Number} durationTo
* @param {ccs.TweenType} tweenEasing
*/
- play:function (durationTo, tweenEasing) {
+ play: function (durationTo, tweenEasing) {
this._isComplete = false;
this._isPause = false;
this._isPlaying = true;
@@ -153,7 +153,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
this._tweenEasing = tweenEasing;
},
- update:function (dt) {
+ update: function (dt) {
if (this._isComplete || this._isPause) {
return false;
}
@@ -165,7 +165,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
if (locNextFrameIndex <= 0) {
this._currentPercent = 1;
locCurrentFrame = 0;
- }else{
+ } else {
/*
* update currentFrame, every update add the frame passed.
* dt/this.animationInternal determine it is not a frame animation. If frame speed changed, it will not make our
@@ -189,7 +189,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
/**
* update will call this handler, you can handle your logic here
*/
- updateHandler:function () {
+ updateHandler: function () {
//override
},
@@ -197,7 +197,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* goto frame
* @param {Number} frameIndex
*/
- gotoFrame:function (frameIndex) {
+ gotoFrame: function (frameIndex) {
var locLoopType = this._loopType;
if (locLoopType == ccs.ANIMATION_TYPE_NO_LOOP) {
locLoopType = ccs.ANIMATION_TYPE_MAX;
@@ -214,8 +214,8 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* get currentFrameIndex
* @return {Number}
*/
- getCurrentFrameIndex:function () {
- this._curFrameIndex = (this._rawDuration-1) * this._currentPercent;
+ getCurrentFrameIndex: function () {
+ this._curFrameIndex = (this._rawDuration - 1) * this._currentPercent;
return this._curFrameIndex;
},
@@ -223,7 +223,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* whether the animation is pause
* @returns {boolean}
*/
- isPause:function () {
+ isPause: function () {
return this._isPause;
},
@@ -231,7 +231,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* whether the animation is complete
* @returns {boolean}
*/
- isComplete:function () {
+ isComplete: function () {
return this._isComplete;
},
@@ -239,7 +239,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* current percent getter
* @returns {number}
*/
- getCurrentPercent:function () {
+ getCurrentPercent: function () {
return this._currentPercent;
},
@@ -247,7 +247,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* rawDuration getter
* @returns {number}
*/
- getRawDuration:function () {
+ getRawDuration: function () {
return this._rawDuration;
},
@@ -255,7 +255,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* loop type getter
* @returns {number}
*/
- getLoop:function () {
+ getLoop: function () {
return this._loopType;
},
@@ -263,7 +263,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* tween easing getter
* @returns {number}
*/
- getTweenEasing:function () {
+ getTweenEasing: function () {
return this._tweenEasing;
},
@@ -271,7 +271,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* animationInternal getter
* @returns {number}
*/
- getAnimationInternal:function () {
+ getAnimationInternal: function () {
return this.animationInternal;
},
@@ -279,7 +279,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* animationInternal setter
* @param animationInternal
*/
- setAnimationInternal:function(animationInternal){
+ setAnimationInternal: function (animationInternal) {
this.animationInternal = animationInternal;
},
@@ -287,7 +287,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* process scale getter
* @returns {number}
*/
- getProcessScale:function () {
+ getProcessScale: function () {
return this.processScale;
},
@@ -295,7 +295,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* process scale setter
* @param processScale
*/
- setProcessScale:function (processScale) {
+ setProcessScale: function (processScale) {
this.processScale = processScale;
},
@@ -303,12 +303,12 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{
* whether the animation is playing
* @returns {boolean}
*/
- isPlaying:function () {
+ isPlaying: function () {
return this._isPlaying;
}
});
-window._p = ccs.ProcessBase.prototype;
+var _p = ccs.ProcessBase.prototype;
// Extended properties
/** @expose */
@@ -336,4 +336,4 @@ cc.defineGetterSetter(_p, "tweenEasing", _p.getTweenEasing);
_p.playing;
cc.defineGetterSetter(_p, "playing", _p.isPlaying);
-delete window._p;
+_p = null;
diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js
index cbcbb98e1e..d77bb8ee1e 100644
--- a/extensions/cocostudio/armature/display/CCSkin.js
+++ b/extensions/cocostudio/armature/display/CCSkin.js
@@ -33,13 +33,13 @@
*
*/
ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
- _skinData:null,
- bone:null,
- _skinTransform:null,
- _displayName:"",
- _armature:null,
- _className:"Skin",
- ctor:function () {
+ _skinData: null,
+ bone: null,
+ _skinTransform: null,
+ _displayName: "",
+ _armature: null,
+ _className: "Skin",
+ ctor: function () {
cc.Sprite.prototype.ctor.call(this);
this._skinData = null;
this.bone = null;
@@ -47,17 +47,17 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
this._skinTransform = cc.AffineTransformIdentity();
this._armature = null;
},
- initWithSpriteFrameName:function(spriteFrameName){
- var ret = cc.Sprite.prototype.initWithSpriteFrameName.call(this,spriteFrameName);
+ initWithSpriteFrameName: function (spriteFrameName) {
+ var ret = cc.Sprite.prototype.initWithSpriteFrameName.call(this, spriteFrameName);
this._displayName = spriteFrameName;
return ret;
},
- initWithFile:function(fileName){
- var ret = cc.Sprite.prototype.initWithFile.call(this,fileName);
+ initWithFile: function (fileName) {
+ var ret = cc.Sprite.prototype.initWithFile.call(this, fileName);
this._displayName = fileName;
return ret;
},
- setSkinData:function (skinData) {
+ setSkinData: function (skinData) {
this._skinData = skinData;
this.setScaleX(skinData.scaleX);
@@ -77,19 +77,19 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
this.updateArmatureTransform();
},
- getSkinData:function () {
+ getSkinData: function () {
return this._skinData;
},
- setBone:function (bone) {
+ setBone: function (bone) {
this.bone = bone;
},
- getBone:function () {
+ getBone: function () {
return this.bone;
},
- updateArmatureTransform:function () {
+ updateArmatureTransform: function () {
this._transform = cc.AffineTransformConcat(this._skinTransform, this.bone.nodeToArmatureTransform());
var locTransform = this._transform;
var locArmature = this._armature;
@@ -109,7 +109,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
* The returned box is relative only to its parent.
* @return {cc.Rect}
*/
- getBoundingBox:function () {
+ getBoundingBox: function () {
var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
var transForm = this.nodeToParentTransform();
return cc.RectApplyAffineTransform(rect, transForm);
@@ -119,7 +119,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
* display name getter
* @returns {String}
*/
- getDisplayName:function(){
+ getDisplayName: function () {
return this._displayName;
},
@@ -141,7 +141,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{
});
ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._nodeToParentTransformForWebGL;
-window._p = ccs.Skin.prototype;
+var _p = ccs.Skin.prototype;
// Extended properties
/** @expose */
@@ -151,7 +151,7 @@ cc.defineGetterSetter(_p, "skinData", _p.getSkinData, _p.setSkinData);
_p.displayName;
cc.defineGetterSetter(_p, "displayName", _p.getDisplayName);
-delete window._p;
+_p = null;
/**
* allocates and initializes a skin.
diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js
index 1451482c34..25dd2b3404 100644
--- a/extensions/cocostudio/armature/physics/CCColliderDetector.js
+++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js
@@ -56,13 +56,13 @@ ccs.ColliderFilter = ccs.Class.extend(/** @lends ccs.ColliderFilter# */{
ccs.ColliderBody = ccs.Class.extend(/** @lends ccs.ColliderBody# */{
shape: null,
coutourData: null,
- colliderFilter:null,
- _calculatedVertexList:null,
+ colliderFilter: null,
+ _calculatedVertexList: null,
ctor: function (contourData) {
this.shape = null;
this.coutourData = contourData;
this.colliderFilter = new ccs.ColliderFilter();
- if(ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX){
+ if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
this._calculatedVertexList = [];
}
},
@@ -119,7 +119,7 @@ ccs.ColliderBody = ccs.Class.extend(/** @lends ccs.ColliderBody# */{
* get calculated vertex list
* @returns {Array}
*/
- getCalculatedVertexList:function(){
+ getCalculatedVertexList: function () {
return this._calculatedVertexList;
}
});
@@ -188,7 +188,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{
removeContourData: function (contourData) {
var locColliderBodyList = this._colliderBodyList;
for (var i = 0; i < locColliderBodyList.length; i++) {
- if(locColliderBodyList[i].getContourData()==contourData){
+ if (locColliderBodyList[i].getContourData() == contourData) {
locColliderBodyList.splice(i, 1);
return;
}
@@ -223,7 +223,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{
* get colliderFilter
* @returns {ccs.ColliderFilter}
*/
- getColliderFilter:function(){
+ getColliderFilter: function () {
return this._filter;
},
@@ -283,14 +283,14 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{
shape.verts[j * 2 + 1] = locHelpPoint.y;
}
if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
- var v = cc.p(0, 0);
+ var v = cc.p(0, 0);
v.x = locHelpPoint.x;
v.y = locHelpPoint.y;
cvs[j] = v;
}
}
if (shape) {
- for (var j = 0; j < vs.length; j++) {
+ for (var j = 0; j < vs.length; j++) {
var b = shape.verts[(j + 1) % shape.verts.length];
var n = cp.v.normalize(cp.v.perp(cp.v.sub(b, shape.verts[j])));
shape.axes[j].n = n;
@@ -318,7 +318,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{
var shape = new cp.PolyShape(this._body, verts, cp.vzero);
shape.sensor = true;
shape.data = this._bone;
- if (this._active){
+ if (this._active) {
this._body.space.addShape(shape);
}
colliderBody.setShape(shape);
@@ -327,7 +327,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{
}
});
-window._p = ccs.ColliderDetector.prototype;
+var _p = ccs.ColliderDetector.prototype;
// Extended properties
/** @expose */
@@ -340,7 +340,7 @@ cc.defineGetterSetter(_p, "active", _p.getActive, _p.setActive);
_p.body;
cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
-delete window._p;
+_p = null;
ccs.ColliderDetector.create = function (bone) {
var colliderDetector = new ccs.ColliderDetector();
diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js
index f460c290d4..f536db4488 100644
--- a/extensions/editbox/CCEditBox.js
+++ b/extensions/editbox/CCEditBox.js
@@ -222,7 +222,7 @@ cc.EditBox = cc.ControlButton.extend({
_placeholderFontSize: 14,
_tooltip: false,
- _className:"EditBox",
+ _className: "EditBox",
/**
* * Constructor.
@@ -234,7 +234,8 @@ cc.EditBox = cc.ControlButton.extend({
this._placeholderColor = cc.color.GRAY;
this.setContentSize(boxSize);
var tmpDOMSprite = this._domInputSprite = new cc.Sprite();
- tmpDOMSprite.draw = function(){ }; //redefine draw function
+ tmpDOMSprite.draw = function () {
+ }; //redefine draw function
this.addChild(tmpDOMSprite);
var selfPointer = this;
var tmpEdTxt = this._edTxt = cc.newElement("input");
@@ -264,7 +265,7 @@ cc.EditBox = cc.ControlButton.extend({
cc._addEventListener(tmpEdTxt, "focus", function () {
if (this.value == selfPointer._placeholderText) {
this.value = "";
- this.style.fontSize = selfPointer._edFontSize + "px" ;
+ this.style.fontSize = selfPointer._edFontSize + "px";
this.style.color = cc.colorToHex(selfPointer._textColor);
}
if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidBegin)
@@ -273,7 +274,7 @@ cc.EditBox = cc.ControlButton.extend({
cc._addEventListener(tmpEdTxt, "blur", function () {
if (this.value == "") {
this.value = selfPointer._placeholderText;
- this.style.fontSize = selfPointer._placeholderFontSize + "px" ;
+ this.style.fontSize = selfPointer._placeholderFontSize + "px";
this.style.color = cc.colorToHex(selfPointer._placeholderColor);
}
if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidEnd)
@@ -285,8 +286,8 @@ cc.EditBox = cc.ControlButton.extend({
cc.DOM.convert(tmpDOMSprite);
tmpDOMSprite.dom.appendChild(tmpEdTxt);
tmpDOMSprite.dom.showTooltipDiv = false;
- tmpDOMSprite.dom.style.width = (boxSize.width - 6) +"px";
- tmpDOMSprite.dom.style.height = (boxSize.height - 6) +"px";
+ tmpDOMSprite.dom.style.width = (boxSize.width - 6) + "px";
+ tmpDOMSprite.dom.style.height = (boxSize.height - 6) + "px";
//this._domInputSprite.dom.style.borderWidth = "1px";
//this._domInputSprite.dom.style.borderStyle = "solid";
@@ -305,20 +306,20 @@ cc.EditBox = cc.ControlButton.extend({
this._setFontToEditBox();
},
- _setFont: function (fontStyle) {
- var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
- if(res) {
- this._edFontSize = parseInt(res[1]);
- this._edFontName = res[2];
- this._setFontToEditBox();
- }
- },
+ _setFont: function (fontStyle) {
+ var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
+ if (res) {
+ this._edFontSize = parseInt(res[1]);
+ this._edFontName = res[2];
+ this._setFontToEditBox();
+ }
+ },
/**
* set fontName
* @param {String} fontName
*/
- setFontName: function(fontName){
+ setFontName: function (fontName) {
this._edFontName = fontName;
this._setFontToEditBox();
},
@@ -327,15 +328,15 @@ cc.EditBox = cc.ControlButton.extend({
* set fontSize
* @param {Number} fontSize
*/
- setFontSize: function(fontSize){
+ setFontSize: function (fontSize) {
this._edFontSize = fontSize;
this._setFontToEditBox();
},
_setFontToEditBox: function () {
- if (this._edTxt.value != this._placeholderText){
+ if (this._edTxt.value != this._placeholderText) {
this._edTxt.style.fontFamily = this._edFontName;
- this._edTxt.style.fontSize = this._edFontSize+"px";
+ this._edTxt.style.fontSize = this._edFontSize + "px";
}
},
@@ -414,14 +415,14 @@ cc.EditBox = cc.ControlButton.extend({
this._placeholderFontSize = fontSize;
this._setPlaceholderFontToEditText();
},
- _setPlaceholderFont: function (fontStyle) {
- var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
- if(res) {
- this._placeholderFontName = res[2];
- this._placeholderFontSize = parseInt(res[1]);
- this._setPlaceholderFontToEditText();
- }
- },
+ _setPlaceholderFont: function (fontStyle) {
+ var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
+ if (res) {
+ this._placeholderFontName = res[2];
+ this._placeholderFontSize = parseInt(res[1]);
+ this._setPlaceholderFontToEditText();
+ }
+ },
/**
* Set the placeholder's fontName.
@@ -442,7 +443,7 @@ cc.EditBox = cc.ControlButton.extend({
},
_setPlaceholderFontToEditText: function () {
- if (this._edTxt.value == this._placeholderText){
+ if (this._edTxt.value == this._placeholderText) {
this._edTxt.style.fontFamily = this._placeholderFontName;
this._edTxt.style.fontSize = this._placeholderFontSize + "px";
}
@@ -488,12 +489,12 @@ cc.EditBox = cc.ControlButton.extend({
initWithSizeAndBackgroundSprite: function (size, normal9SpriteBg) {
if (this.initWithBackgroundSprite(normal9SpriteBg)) {
this._domInputSprite.x = 3;
- this._domInputSprite.y = 3;
+ this._domInputSprite.y = 3;
this.setZoomOnTouchDown(false);
this.setPreferredSize(size);
this.x = 0;
- this.y = 0;
+ this.y = 0;
this._addTargetWithActionForControlEvent(this, this.touchDownAction, cc.CONTROL_EVENT_TOUCH_UP_INSIDE);
return true;
}
@@ -573,7 +574,7 @@ cc.EditBox = cc.ControlButton.extend({
}
});
-window._p = cc.EditBox.prototype;
+var _p = cc.EditBox.prototype;
// Extended properties
/** @expose */
@@ -622,7 +623,7 @@ cc.defineGetterSetter(_p, "inputMode", null, _p.setInputMode);
_p.returnType;
cc.defineGetterSetter(_p, "returnType", null, _p.setReturnType);
-delete window._p;
+_p = null;
cc.EditBox.getRect = function (node) {
var contentSize = node.getContentSize();
diff --git a/extensions/gui/control-extension/CCControl.js b/extensions/gui/control-extension/CCControl.js
index 23c583d98d..d2b83b053d 100644
--- a/extensions/gui/control-extension/CCControl.js
+++ b/extensions/gui/control-extension/CCControl.js
@@ -64,15 +64,15 @@ cc.CONTROL_STATE_INITIAL = 1 << 3;
* @property {Boolean} highlighted - Indicate whether the control node is highlighted
*/
cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
- _isOpacityModifyRGB:false,
- _hasVisibleParents:false,
+ _isOpacityModifyRGB: false,
+ _hasVisibleParents: false,
_touchListener: null,
- _className:"Control",
+ _className: "Control",
- isOpacityModifyRGB:function () {
+ isOpacityModifyRGB: function () {
return this._isOpacityModifyRGB;
},
- setOpacityModifyRGB:function (opacityModifyRGB) {
+ setOpacityModifyRGB: function (opacityModifyRGB) {
this._isOpacityModifyRGB = opacityModifyRGB;
var children = this.getChildren();
@@ -84,28 +84,28 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
},
/** The current control state constant. */
- _state:cc.CONTROL_STATE_NORMAL,
- getState:function () {
+ _state: cc.CONTROL_STATE_NORMAL,
+ getState: function () {
return this._state;
},
- _enabled:false,
- _selected:false,
- _highlighted:false,
+ _enabled: false,
+ _selected: false,
+ _highlighted: false,
- _dispatchTable:null,
+ _dispatchTable: null,
/**
* Tells whether the control is enabled
* @param {Boolean} enabled
*/
- setEnabled:function (enabled) {
+ setEnabled: function (enabled) {
this._enabled = enabled;
- this._state = enabled ? cc.CONTROL_STATE_NORMAL:cc.CONTROL_STATE_DISABLED;
+ this._state = enabled ? cc.CONTROL_STATE_NORMAL : cc.CONTROL_STATE_DISABLED;
this.needsLayout();
},
- isEnabled:function () {
+ isEnabled: function () {
return this._enabled;
},
@@ -113,11 +113,11 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* A Boolean value that determines the control selected state.
* @param {Boolean} selected
*/
- setSelected:function (selected) {
+ setSelected: function (selected) {
this._selected = selected;
this.needsLayout();
},
- isSelected:function () {
+ isSelected: function () {
return this._selected;
},
@@ -125,15 +125,15 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* A Boolean value that determines whether the control is highlighted.
* @param {Boolean} highlighted
*/
- setHighlighted:function (highlighted) {
+ setHighlighted: function (highlighted) {
this._highlighted = highlighted;
this.needsLayout();
},
- isHighlighted:function () {
+ isHighlighted: function () {
return this._highlighted;
},
- hasVisibleParents:function () {
+ hasVisibleParents: function () {
var parent = this.getParent();
for (var c = parent; c != null; c = c.getParent()) {
if (!c.isVisible())
@@ -142,13 +142,13 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
return true;
},
- ctor:function () {
+ ctor: function () {
cc.LayerRGBA.prototype.ctor.call(this);
this._dispatchTable = {};
this._color = cc.color.WHITE;
},
- init:function () {
+ init: function () {
if (cc.LayerRGBA.prototype.init.call(this)) {
// Initialise instance variables
this._state = cc.CONTROL_STATE_NORMAL;
@@ -159,13 +159,13 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
var listener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE
});
- if(this.onTouchBegan)
+ if (this.onTouchBegan)
listener.onTouchBegan = this.onTouchBegan.bind(this);
- if(this.onTouchMoved)
+ if (this.onTouchMoved)
listener.onTouchMoved = this.onTouchMoved.bind(this);
- if(this.onTouchEnded)
+ if (this.onTouchEnded)
listener.onTouchEnded = this.onTouchEnded.bind(this);
- if(this.onTouchCancelled)
+ if (this.onTouchCancelled)
listener.onTouchCancelled = this.onTouchCancelled.bind(this);
this._touchListener = listener;
return true;
@@ -173,9 +173,9 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
return false;
},
- onEnter: function(){
+ onEnter: function () {
var locListener = this._touchListener;
- if(!locListener._isRegistered())
+ if (!locListener._isRegistered())
cc.eventManager.addListener(locListener, this);
cc.Node.prototype.onEnter.call(this);
},
@@ -185,7 +185,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* which action messages are sent. See "CCControlEvent" for bitmask constants.
* @param {Number} controlEvents A bitmask whose set flags specify the control events for
*/
- sendActionsForControlEvents:function (controlEvents) {
+ sendActionsForControlEvents: function (controlEvents) {
// For each control events
for (var i = 0, len = cc.CONTROL_EVENT_TOTAL_NUMBER; i < len; i++) {
// If the given controlEvents bitmask contains the curent event
@@ -212,7 +212,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param {function} action A selector identifying an action message. It cannot be NULL.
* @param {Number} controlEvents A bitmask specifying the control events for which the action message is sent. See "CCControlEvent" for bitmask constants.
*/
- addTargetWithActionForControlEvents:function (target, action, controlEvents) {
+ addTargetWithActionForControlEvents: function (target, action, controlEvents) {
// For each control events
for (var i = 0, len = cc.CONTROL_EVENT_TOTAL_NUMBER; i < len; i++) {
// If the given controlEvents bit mask contains the current event
@@ -228,7 +228,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param {function} action A selector identifying an action message. Pass NULL to remove all action messages paired with target.
* @param {Number} controlEvents A bitmask specifying the control events associated with target and action. See "CCControlEvent" for bitmask constants.
*/
- removeTargetWithActionForControlEvents:function (target, action, controlEvents) {
+ removeTargetWithActionForControlEvents: function (target, action, controlEvents) {
// For each control events
for (var i = 0, len = cc.CONTROL_EVENT_TOTAL_NUMBER; i < len; i++) {
// If the given controlEvents bitmask contains the current event
@@ -242,7 +242,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* control space coordinates.
* @param {cc.Touch} touch A CCTouch object that represents a touch.
*/
- getTouchLocation:function (touch) {
+ getTouchLocation: function (touch) {
var touchLocation = touch.getLocation(); // Get the touch position
return this.convertToNodeSpace(touchLocation); // Convert to the node space of this class
},
@@ -253,7 +253,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param {cc.Touch} touch A cc.Touch object that represents a touch.
* @return {Boolean} YES whether a touch is inside the receiver's rect.
*/
- isTouchInside:function (touch) {
+ isTouchInside: function (touch) {
var touchLocation = touch.getLocation(); // Get the touch position
touchLocation = this.getParent().convertToNodeSpace(touchLocation);
return cc.rectContainsPoint(this.getBoundingBox(), touchLocation);
@@ -271,7 +271,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
*
* @return {cc.Invocation} an CCInvocation object able to construct messages using a given target-action pair.
*/
- _invocationWithTargetAndActionForControlEvent:function (target, action, controlEvent) {
+ _invocationWithTargetAndActionForControlEvent: function (target, action, controlEvent) {
return null;
},
@@ -281,7 +281,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param {Number} controlEvent A control events for which the action message is sent. See "CCControlEvent" for constants.
* @return {cc.Invocation} the cc.Invocation list for the given control event.
*/
- _dispatchListforControlEvent:function (controlEvent) {
+ _dispatchListforControlEvent: function (controlEvent) {
controlEvent = controlEvent.toString();
// If the invocation list does not exist for the dispatch table, we create it
if (!this._dispatchTable[controlEvent])
@@ -302,7 +302,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param controlEvent A control event for which the action message is sent.
* See "CCControlEvent" for constants.
*/
- _addTargetWithActionForControlEvent:function (target, action, controlEvent) {
+ _addTargetWithActionForControlEvent: function (target, action, controlEvent) {
// Create the invocation object
var invocation = new cc.Invocation(target, action, controlEvent);
@@ -318,7 +318,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
* @param {function} action A selector identifying an action message. Pass NULL to remove all action messages paired with target.
* @param {Number} controlEvent A control event for which the action message is sent. See "CCControlEvent" for constants.
*/
- _removeTargetWithActionForControlEvent:function (target, action, controlEvent) {
+ _removeTargetWithActionForControlEvent: function (target, action, controlEvent) {
// Retrieve all invocations for the given control event
//
var eventInvocationList = this._dispatchListforControlEvent(controlEvent);
@@ -331,7 +331,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
eventInvocationList.length = 0;
} else {
//normally we would use a predicate, but this won't work here. Have to do it manually
- for (var i = 0; i < eventInvocationList.length; ) {
+ for (var i = 0; i < eventInvocationList.length;) {
var invocation = eventInvocationList[i];
var shouldBeRemoved = true;
if (target)
@@ -342,7 +342,7 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
if (shouldBeRemoved)
cc.arrayRemoveObject(eventInvocationList, invocation);
else
- i ++;
+ i++;
}
}
},
@@ -350,11 +350,11 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{
/**
* Updates the control layout using its current internal state.
*/
- needsLayout:function () {
+ needsLayout: function () {
}
});
-window._p = cc.Control.prototype;
+var _p = cc.Control.prototype;
// Extended properties
/** @expose */
@@ -370,7 +370,7 @@ cc.defineGetterSetter(_p, "selected", _p.isSelected, _p.setSelected);
_p.highlighted;
cc.defineGetterSetter(_p, "highlighted", _p.isHighlighted, _p.setHighlighted);
-delete window._p;
+_p = null;
cc.Control.create = function () {
var retControl = new cc.Control();
diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js
index 19c451fe9c..132966f4b9 100644
--- a/extensions/gui/control-extension/CCControlButton.js
+++ b/extensions/gui/control-extension/CCControlButton.js
@@ -40,27 +40,27 @@ cc.CONTROL_ZOOM_ACTION_TAG = 0xCCCB0001;
* @property {Boolean} labelAnchor - The anchor point for the label of the control button
*/
cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
- _doesAdjustBackgroundImage:false,
- zoomOnTouchDown:false,
+ _doesAdjustBackgroundImage: false,
+ zoomOnTouchDown: false,
_preferredSize: null,
_labelAnchorPoint: null,
_currentTitle: null,
_currentTitleColor: null,
- _titleLabel:null,
- _backgroundSprite:null,
- _opacity:0,
- _isPushed:false,
- _titleDispatchTable:null,
- _titleColorDispatchTable:null,
- _titleLabelDispatchTable:null,
- _backgroundSpriteDispatchTable:null,
- _parentInited:false,
-
- _marginV:0,
- _marginH:0,
- _className:"ControlButton",
-
- ctor:function () {
+ _titleLabel: null,
+ _backgroundSprite: null,
+ _opacity: 0,
+ _isPushed: false,
+ _titleDispatchTable: null,
+ _titleColorDispatchTable: null,
+ _titleLabelDispatchTable: null,
+ _backgroundSpriteDispatchTable: null,
+ _parentInited: false,
+
+ _marginV: 0,
+ _marginH: 0,
+ _className: "ControlButton",
+
+ ctor: function () {
cc.Control.prototype.ctor.call(this);
this._preferredSize = cc.size(0, 0);
this._labelAnchorPoint = cc.p(0, 0);
@@ -72,18 +72,18 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
this._backgroundSpriteDispatchTable = {};
},
- init:function () {
+ init: function () {
return this.initWithLabelAndBackgroundSprite(cc.LabelTTF.create("", "Arial", 12), cc.Scale9Sprite.create());
},
- needsLayout:function () {
+ needsLayout: function () {
if (!this._parentInited) {
return;
}
// Hide the background and the label
- if(this._titleLabel)
+ if (this._titleLabel)
this._titleLabel.setVisible(false);
- if(this._backgroundSprite)
+ if (this._backgroundSprite)
this._backgroundSprite.setVisible(false);
// Update anchor of all labels
@@ -104,18 +104,18 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
label.setColor(this._currentTitleColor);
var locContentSize = this.getContentSize();
- if(label)
+ if (label)
label.setPosition(locContentSize.width / 2, locContentSize.height / 2);
// Update the background sprite
this._backgroundSprite = this.getBackgroundSpriteForState(locState);
var locBackgroundSprite = this._backgroundSprite;
- if(locBackgroundSprite)
+ if (locBackgroundSprite)
locBackgroundSprite.setPosition(locContentSize.width / 2, locContentSize.height / 2);
// Get the title label size
var titleLabelSize = cc.size(0, 0);
- if(label){
+ if (label) {
var boundingBox = label.getBoundingBox();
titleLabelSize.width = boundingBox.width;
titleLabelSize.height = boundingBox.height;
@@ -123,11 +123,11 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
// Adjust the background image if necessary
if (this._doesAdjustBackgroundImage) {
// Add the margins
- if(locBackgroundSprite)
+ if (locBackgroundSprite)
locBackgroundSprite.setContentSize(titleLabelSize.width + this._marginH * 2, titleLabelSize.height + this._marginV * 2);
} else {
//TODO: should this also have margins if one of the preferred sizes is relaxed?
- if(locBackgroundSprite){
+ if (locBackgroundSprite) {
var preferredSize = locBackgroundSprite.getPreferredSize();
preferredSize = cc.size(preferredSize.width, preferredSize.height);
if (preferredSize.width <= 0)
@@ -140,25 +140,25 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
}
// Set the content size
- var rectTitle = label? label.getBoundingBox():cc.rect(0,0,0,0);
- var rectBackground = locBackgroundSprite? locBackgroundSprite.getBoundingBox():cc.rect(0,0,0,0);
+ var rectTitle = label ? label.getBoundingBox() : cc.rect(0, 0, 0, 0);
+ var rectBackground = locBackgroundSprite ? locBackgroundSprite.getBoundingBox() : cc.rect(0, 0, 0, 0);
var maxRect = cc.rectUnion(rectTitle, rectBackground);
this.setContentSize(maxRect.width, maxRect.height);
locContentSize = this.getContentSize();
- if(label){
+ if (label) {
label.setPosition(locContentSize.width / 2, locContentSize.height / 2);
label.setVisible(true);
}
- if(locBackgroundSprite){
+ if (locBackgroundSprite) {
locBackgroundSprite.setPosition(locContentSize.width / 2, locContentSize.height / 2);
locBackgroundSprite.setVisible(true);
}
},
- initWithLabelAndBackgroundSprite:function (label, backgroundSprite) {
- if(!label || !label.RGBAProtocol)
+ initWithLabelAndBackgroundSprite: function (label, backgroundSprite) {
+ if (!label || !label.RGBAProtocol)
throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null";
- if(!backgroundSprite)
+ if (!backgroundSprite)
throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): backgroundSprite should be non-null";
if (cc.Control.prototype.init.call(this, true)) {
this._parentInited = true;
@@ -176,7 +176,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
// Adjust the background image by default
this.setAdjustBackgroundImage(true);
- this.setPreferredSize(cc.size(0,0));
+ this.setPreferredSize(cc.size(0, 0));
// Zooming button by default
this.zoomOnTouchDown = true;
@@ -219,12 +219,12 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
return false;
},
- initWithTitleAndFontNameAndFontSize:function (title, fontName, fontSize) {
+ initWithTitleAndFontNameAndFontSize: function (title, fontName, fontSize) {
var label = cc.LabelTTF.create(title, fontName, fontSize);
return this.initWithLabelAndBackgroundSprite(label, cc.Scale9Sprite.create());
},
- initWithBackgroundSprite:function (sprite) {
+ initWithBackgroundSprite: function (sprite) {
var label = cc.LabelTTF.create("", "Arial", 30);//
return this.initWithLabelAndBackgroundSprite(label, sprite);
},
@@ -233,30 +233,30 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* Adjust the background image. YES by default. If the property is set to NO, the background will use the prefered size of the background image.
* @return {Boolean}
*/
- doesAdjustBackgroundImage:function () {
+ doesAdjustBackgroundImage: function () {
return this._doesAdjustBackgroundImage;
},
- setAdjustBackgroundImage:function (adjustBackgroundImage) {
+ setAdjustBackgroundImage: function (adjustBackgroundImage) {
this._doesAdjustBackgroundImage = adjustBackgroundImage;
this.needsLayout();
},
/** Adjust the button zooming on touchdown. Default value is YES. */
- getZoomOnTouchDown:function () {
+ getZoomOnTouchDown: function () {
return this.zoomOnTouchDown;
},
- setZoomOnTouchDown:function (zoomOnTouchDown) {
+ setZoomOnTouchDown: function (zoomOnTouchDown) {
return this.zoomOnTouchDown = zoomOnTouchDown;
},
/** The prefered size of the button, if label is larger it will be expanded. */
- getPreferredSize:function () {
+ getPreferredSize: function () {
return this._preferredSize;
},
- setPreferredSize:function (size) {
+ setPreferredSize: function (size) {
if (size.width === 0 && size.height === 0) {
this._doesAdjustBackgroundImage = true;
} else {
@@ -269,12 +269,12 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
this.needsLayout();
},
- getLabelAnchorPoint:function () {
+ getLabelAnchorPoint: function () {
return this._labelAnchorPoint;
},
- setLabelAnchorPoint:function (labelAnchorPoint) {
+ setLabelAnchorPoint: function (labelAnchorPoint) {
this._labelAnchorPoint = labelAnchorPoint;
- if(this._titleLabel)
+ if (this._titleLabel)
this._titleLabel.setAnchorPoint(labelAnchorPoint);
},
@@ -282,59 +282,59 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* The current title that is displayed on the button.
* @return {string}
*/
- _getCurrentTitle:function () {
+ _getCurrentTitle: function () {
return this._currentTitle;
},
/** The current color used to display the title. */
- _getCurrentTitleColor:function () {
+ _getCurrentTitleColor: function () {
return this._currentTitleColor;
},
/* Override setter to affect a background sprite too */
- getOpacity:function () {
+ getOpacity: function () {
return this._opacity;
},
- setOpacity:function (opacity) {
+ setOpacity: function (opacity) {
// XXX fixed me if not correct
cc.Control.prototype.setOpacity.call(this, opacity);
/*this._opacity = opacity;
- var controlChildren = this.getChildren();
- for (var i = 0; i < controlChildren.length; i++) {
- var selChild = controlChildren[i];
- if (selChild && selChild.RGBAProtocol)
- selChild.setOpacity(opacity);
- }*/
+ var controlChildren = this.getChildren();
+ for (var i = 0; i < controlChildren.length; i++) {
+ var selChild = controlChildren[i];
+ if (selChild && selChild.RGBAProtocol)
+ selChild.setOpacity(opacity);
+ }*/
var locTable = this._backgroundSpriteDispatchTable;
for (var itemKey in locTable)
locTable[itemKey].setOpacity(opacity);
},
- setColor:function(color){
- cc.Control.prototype.setColor.call(this,color);
+ setColor: function (color) {
+ cc.Control.prototype.setColor.call(this, color);
var locTable = this._backgroundSpriteDispatchTable;
- for(var key in locTable)
+ for (var key in locTable)
locTable[key].setColor(color);
},
- getColor:function(){
+ getColor: function () {
var locRealColor = this._realColor;
return cc.color(locRealColor.r, locRealColor.g, locRealColor.b, locRealColor.a);
},
/** Flag to know if the button is currently pushed. */
- isPushed:function () {
+ isPushed: function () {
return this._isPushed;
},
/* Define the button margin for Top/Bottom edge */
- _getVerticalMargin:function () {
+ _getVerticalMargin: function () {
return this._marginV;
},
/* Define the button margin for Left/Right edge */
- _getHorizontalOrigin:function () {
+ _getHorizontalOrigin: function () {
return this._marginH;
},
@@ -343,23 +343,23 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Number} marginH
* @param {Number} marginV
*/
- setMargins:function (marginH, marginV) {
+ setMargins: function (marginH, marginV) {
this._marginV = marginV;
this._marginH = marginH;
this.needsLayout();
},
- setEnabled:function (enabled) {
+ setEnabled: function (enabled) {
cc.Control.prototype.setEnabled.call(this, enabled);
this.needsLayout();
},
- setSelected:function (enabled) {
+ setSelected: function (enabled) {
cc.Control.prototype.setSelected.call(this, enabled);
this.needsLayout();
},
- setHighlighted:function (enabled) {
- this._state = enabled?cc.CONTROL_STATE_HIGHLIGHTED:cc.CONTROL_STATE_NORMAL;
+ setHighlighted: function (enabled) {
+ this._state = enabled ? cc.CONTROL_STATE_HIGHLIGHTED : cc.CONTROL_STATE_NORMAL;
cc.Control.prototype.setHighlighted.call(this, enabled);
var action = this.getActionByTag(cc.CONTROL_ZOOM_ACTION_TAG);
@@ -375,8 +375,8 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
}
},
- onTouchBegan:function (touch, event) {
- if (!this.isTouchInside(touch) || !this.isEnabled()|| !this.isVisible()||!this.hasVisibleParents())
+ onTouchBegan: function (touch, event) {
+ if (!this.isTouchInside(touch) || !this.isEnabled() || !this.isVisible() || !this.hasVisibleParents())
return false;
this._isPushed = true;
@@ -385,7 +385,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
return true;
},
- onTouchMoved:function (touch, event) {
+ onTouchMoved: function (touch, event) {
if (!this._enabled || !this._isPushed || this._selected) {
if (this._highlighted)
this.setHighlighted(false);
@@ -405,7 +405,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE);
}
},
- onTouchEnded:function (touch, event) {
+ onTouchEnded: function (touch, event) {
this._isPushed = false;
this.setHighlighted(false);
@@ -416,7 +416,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
}
},
- onTouchCancelled:function (touch, event) {
+ onTouchCancelled: function (touch, event) {
this._isPushed = false;
this.setHighlighted(false);
this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_CANCEL);
@@ -428,7 +428,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Number} state The state that uses the title. Possible values are described in "CCControlState".
* @return {string} The title for the specified state.
*/
- getTitleForState:function (state) {
+ getTitleForState: function (state) {
var locTable = this._titleDispatchTable;
if (locTable) {
if (locTable[state])
@@ -446,7 +446,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {string} title The title string to use for the specified state.
* @param {Number} state The state that uses the specified title. The values are described in "CCControlState".
*/
- setTitleForState:function (title, state) {
+ setTitleForState: function (title, state) {
this._titleDispatchTable[state] = title || "";
// If the current state if equal to the given state we update the layout
@@ -476,7 +476,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {cc.Color} color The color of the title to use for the specified state.
* @param {Number} state The state that uses the specified color. The values are described in "CCControlState".
*/
- setTitleColorForState:function (color, state) {
+ setTitleColorForState: function (color, state) {
//ccColor3B* colorValue=&color;
this._titleColorDispatchTable[state] = color;
@@ -491,7 +491,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param state The state that uses the title label. Possible values are described in "CCControlState".
* @return {cc.Node} the title label used for a state.
*/
- getTitleLabelForState:function (state) {
+ getTitleLabelForState: function (state) {
var locTable = this._titleLabelDispatchTable;
if (locTable[state])
return locTable[state];
@@ -506,7 +506,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {cc.Node} titleLabel The title label to use for the specified state.
* @param {Number} state The state that uses the specified title. The values are described in "CCControlState".
*/
- setTitleLabelForState:function (titleLabel, state) {
+ setTitleLabelForState: function (titleLabel, state) {
var locTable = this._titleLabelDispatchTable;
if (locTable[state]) {
var previousLabel = locTable[state];
@@ -529,7 +529,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {string} fntFile
* @param {Number} state
*/
- setTitleTTFForState:function (fntFile, state) {
+ setTitleTTFForState: function (fntFile, state) {
var title = this.getTitleForState(state);
if (!title)
title = "";
@@ -541,7 +541,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Number} state
* @returns {string}
*/
- getTitleTTFForState:function (state) {
+ getTitleTTFForState: function (state) {
var labelTTF = this.getTitleLabelForState(state);
if ((labelTTF != null) && (labelTTF instanceof cc.LabelTTF)) {
return labelTTF.getFontName();
@@ -554,7 +554,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Number} size
* @param {Number} state
*/
- setTitleTTFSizeForState:function (size, state) {
+ setTitleTTFSizeForState: function (size, state) {
var labelTTF = this.getTitleLabelForState(state);
if ((labelTTF != null) && (labelTTF instanceof cc.LabelTTF)) {
labelTTF.setFontSize(size);
@@ -566,7 +566,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Number} state
* @returns {Number}
*/
- getTitleTTFSizeForState:function (state) {
+ getTitleTTFSizeForState: function (state) {
var labelTTF = this.getTitleLabelForState(state);
if ((labelTTF != null) && (labelTTF instanceof cc.LabelTTF)) {
return labelTTF.getFontSize();
@@ -579,14 +579,14 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {string} fntFile The name of the font to change to
* @param {Number} state The state that uses the specified fntFile. The values are described in "CCControlState".
*/
- setTitleBMFontForState:function (fntFile, state) {
+ setTitleBMFontForState: function (fntFile, state) {
var title = this.getTitleForState(state);
if (!title)
title = "";
this.setTitleLabelForState(cc.LabelBMFont.create(title, fntFile), state);
},
- getTitleBMFontForState:function (state) {
+ getTitleBMFontForState: function (state) {
var labelBMFont = this.getTitleLabelForState(state);
if ((labelBMFont != null) && (labelBMFont instanceof cc.LabelBMFont)) {
return labelBMFont.getFntFile();
@@ -599,7 +599,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
*
* @param {Number} state The state that uses the background sprite. Possible values are described in "CCControlState".
*/
- getBackgroundSpriteForState:function (state) {
+ getBackgroundSpriteForState: function (state) {
var locTable = this._backgroundSpriteDispatchTable;
if (locTable[state]) {
return locTable[state];
@@ -613,7 +613,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {Scale9Sprite} sprite The background sprite to use for the specified state.
* @param {Number} state The state that uses the specified image. The values are described in "CCControlState".
*/
- setBackgroundSpriteForState:function (sprite, state) {
+ setBackgroundSpriteForState: function (sprite, state) {
var locTable = this._backgroundSpriteDispatchTable;
if (locTable[state]) {
var previousSprite = locTable[state];
@@ -642,13 +642,13 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{
* @param {SpriteFrame} spriteFrame The background spriteFrame to use for the specified state.
* @param {Number} state The state that uses the specified image. The values are described in "CCControlState".
*/
- setBackgroundSpriteFrameForState:function (spriteFrame, state) {
+ setBackgroundSpriteFrameForState: function (spriteFrame, state) {
var sprite = cc.Scale9Sprite.createWithSpriteFrame(spriteFrame);
this.setBackgroundSpriteForState(sprite, state);
}
});
-window._p = cc.ControlButton.prototype;
+var _p = cc.ControlButton.prototype;
// Extended properties
/** @expose */
@@ -661,9 +661,9 @@ cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredS
_p.labelAnchor;
cc.defineGetterSetter(_p, "labelAnchor", _p.getLabelAnchorPoint, _p.setLabelAnchorPoint);
-delete window._p;
+_p = null;
-cc.ControlButton.create = function(label, backgroundSprite) {
+cc.ControlButton.create = function (label, backgroundSprite) {
var controlButton;
if (arguments.length == 0) {
controlButton = new cc.ControlButton();
diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js
index d74cbf30d4..cde810b43a 100644
--- a/extensions/gui/control-extension/CCControlColourPicker.js
+++ b/extensions/gui/control-extension/CCControlColourPicker.js
@@ -160,14 +160,14 @@ cc.ControlColourPicker = cc.Control.extend(/** @lends cc.ControlColourPicker# */
}
});
-window._p = cc.ControlColourPicker.prototype;
+var _p = cc.ControlColourPicker.prototype;
// Extended properties
/** @expose */
_p.background;
cc.defineGetterSetter(_p, "background", _p.getBackground);
-delete window._p;
+_p = null;
cc.ControlColourPicker.create = function () {
var pRet = new cc.ControlColourPicker();
diff --git a/extensions/gui/control-extension/CCControlHuePicker.js b/extensions/gui/control-extension/CCControlHuePicker.js
index b0f4a38646..e4543d1ff6 100644
--- a/extensions/gui/control-extension/CCControlHuePicker.js
+++ b/extensions/gui/control-extension/CCControlHuePicker.js
@@ -174,7 +174,7 @@ cc.ControlHuePicker = cc.Control.extend(/** @lends cc.ControlHuePicker# */{
}
});
-window._p = cc.ControlHuePicker.prototype;
+var _p = cc.ControlHuePicker.prototype;
// Extended properties
/** @expose */
@@ -193,7 +193,7 @@ cc.defineGetterSetter(_p, "slider", _p.getSlider);
_p.startPos;
cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
-delete window._p;
+_p = null;
cc.ControlHuePicker.create = function (target, pos) {
var pRet = new cc.ControlHuePicker();
diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js
index 134aaf8303..c4cf3f9325 100644
--- a/extensions/gui/control-extension/CCControlPotentiometer.js
+++ b/extensions/gui/control-extension/CCControlPotentiometer.js
@@ -246,7 +246,7 @@ cc.ControlPotentiometer = cc.Control.extend(/** @lends cc.ControlPotentiometer#
}
});
-window._p = cc.ControlPotentiometer.prototype;
+var _p = cc.ControlPotentiometer.prototype;
// Extended properties
/** @expose */
@@ -268,7 +268,7 @@ cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite, _p.setThumbSprite);
_p.prevLocation;
cc.defineGetterSetter(_p, "prevLocation", _p.getPreviousLocation, _p.setPreviousLocation);
-delete window._p;
+_p = null;
cc.ControlPotentiometer.create = function (backgroundFile, progressFile, thumbFile) {
var pRet = new cc.ControlPotentiometer();
diff --git a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js
index 174e6417f4..5117ac0508 100644
--- a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js
+++ b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js
@@ -208,7 +208,7 @@ cc.ControlSaturationBrightnessPicker = cc.Control.extend(/** @lends cc.ControlSa
}
});
-window._p = cc.ControlSaturationBrightnessPicker.prototype;
+var _p = cc.ControlSaturationBrightnessPicker.prototype;
// Extended properties
/** @expose */
@@ -233,7 +233,7 @@ cc.defineGetterSetter(_p, "slider", _p.getSlider);
_p.startPos;
cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
-delete window._p;
+_p = null;
cc.ControlSaturationBrightnessPicker.create = function (target, pos) {
var pRet = new cc.ControlSaturationBrightnessPicker();
diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js
index 80eab4418a..ed1016fee5 100644
--- a/extensions/gui/control-extension/CCControlSlider.js
+++ b/extensions/gui/control-extension/CCControlSlider.js
@@ -248,7 +248,7 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{
}
});
-window._p = cc.ControlSlider.prototype;
+var _p = cc.ControlSlider.prototype;
// Extended properties
/** @expose */
@@ -276,7 +276,7 @@ cc.defineGetterSetter(_p, "progressSprite", _p.getProgressSprite);
_p.backgroundSprite;
cc.defineGetterSetter(_p, "backgroundSprite", _p.getBackgroundSprite);
-delete window._p;
+_p = null;
/**
* Creates a slider with a given background sprite and a progress bar and a
diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js
index a8d4ddbba3..926e7855ff 100644
--- a/extensions/gui/control-extension/CCControlStepper.js
+++ b/extensions/gui/control-extension/CCControlStepper.js
@@ -337,7 +337,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{
}
});
-window._p = cc.ControlStepper.prototype;
+var _p = cc.ControlStepper.prototype;
// Extedned properties
/** @expose */
@@ -371,7 +371,7 @@ cc.defineGetterSetter(_p, "minusLabel", _p.getMinusLabel, _p.setMinusLabel);
_p.plusLabel;
cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel);
-delete window._p;
+_p = null;
cc.ControlStepper.create = function (minusSprite, plusSprite) {
var pRet = new cc.ControlStepper();
diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js
index d5900cb547..45f82dbef2 100644
--- a/extensions/gui/control-extension/CCControlSwitch.js
+++ b/extensions/gui/control-extension/CCControlSwitch.js
@@ -380,7 +380,7 @@ cc.ControlSwitchSprite = cc.Sprite.extend({
}
});
-window._p = cc.ControlSwitchSprite.prototype;
+var _p = cc.ControlSwitchSprite.prototype;
/** @expose */
_p.sliderX;
@@ -419,4 +419,4 @@ cc.defineGetterSetter(_p, "onSideWidth", _p._getOnSideWidth);
_p.offSideWidth;
cc.defineGetterSetter(_p, "offSideWidth", _p._getOffSideWidth);
-delete window._p;
+_p = null;
diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js
index e8f51b157e..3475349b50 100644
--- a/extensions/gui/control-extension/CCScale9Sprite.js
+++ b/extensions/gui/control-extension/CCScale9Sprite.js
@@ -902,7 +902,7 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
}
});
-window._p = cc.Scale9Sprite.prototype;
+var _p = cc.Scale9Sprite.prototype;
// Extended properties
/** @expose */
@@ -924,7 +924,7 @@ cc.defineGetterSetter(_p, "insetRight", _p.getInsetRight, _p.setInsetRight);
_p.insetBottom;
cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom);
-delete window._p;
+_p = null;
/**
* Creates a 9-slice sprite with a texture file, a delimitation zone and
diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js
index b534f9c88a..e7cf71cf58 100644
--- a/extensions/gui/scrollview/CCScrollView.js
+++ b/extensions/gui/scrollview/CCScrollView.js
@@ -885,7 +885,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{
}
});
-window._p = cc.ScrollView.prototype;
+var _p = cc.ScrollView.prototype;
// Extended properties
/** @expose */
@@ -913,7 +913,7 @@ cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
_p.clippingToBounds;
cc.defineGetterSetter(_p, "clippingToBounds", _p.isClippingToBounds, _p.setClippingToBounds);
-delete window._p;
+_p = null;
/**
* Returns an autoreleased scroll view object.
diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js
index a001a8a3b7..5fb7d9b1ed 100644
--- a/extensions/gui/scrollview/CCTableView.js
+++ b/extensions/gui/scrollview/CCTableView.js
@@ -74,13 +74,13 @@ cc.TableViewCell = cc.Node.extend(/** @lends cc.TableViewCell# */{
}
});
-window._p = cc.TableViewCell.prototype;
+var _p = cc.TableViewCell.prototype;
/** @expose */
_p.objectId;
cc.defineGetterSetter(_p, "objectId", _p.getObjectID, _p.setObjectID);
-delete window._p;
+_p = null;
/**
* Sole purpose of this delegate is to single touch event in this version.
@@ -678,7 +678,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{
}
});
-window._p = cc.TableView.prototype;
+var _p = cc.TableView.prototype;
/** @expose */
_p.dataSource;
@@ -690,7 +690,7 @@ cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
_p.verticalFillOrder;
cc.defineGetterSetter(_p, "verticalFillOrder", _p.getVerticalFillOrder, _p.setVerticalFillOrder);
-delete window._p;
+_p = null;
/**
* An initialized table view object
From f08640688d3cbb9cb47e703d966ae59d5740f053 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Mon, 14 Apr 2014 17:02:18 +0800
Subject: [PATCH 0011/1564] Issue #4757: update the CHANGELOG.txt and
README.mdown
---
CHANGELOG.txt | 2 +-
README.mdown | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 19a2bcbeb8..b4b4164a5e 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -12,7 +12,7 @@ Cocos2d-html5-v3.0 alpha2 @ April.14, 2014
* cc.Node's pauseSchedulerAndActions and resumeSchedulerAndActions are deprecated, please use pause and resume instead.
* Add render mode checking to 3D action classes.
* Use undefined check in cc.loader for better performance.
-* Sync cc.eventManager to the latest version of Cocos2d-x v3.0 Stable.
+* Sync cc.eventManager to the latest version of Cocos2d-x v3.0 final.
* ccui.Layout's doLayout function has been set to private function "_doLayout".
* Rename all Uppercase functions to lowercase in CCMacro.js.
* Add more necessary GL constants in engine.
diff --git a/README.mdown b/README.mdown
index 503e6af636..64bd5efde7 100644
--- a/README.mdown
+++ b/README.mdown
@@ -14,6 +14,7 @@ Cross Platform
Documentation
------------------
* Website: [www.cocos2d-x.org][3]
+ * API References: [http://www.cocos2d-x.org/wiki/Reference] [4]
Running the tests
------------------
From cc3b0ae375189c66950835f1f9c0c81dbd9f98e7 Mon Sep 17 00:00:00 2001
From: joshua
Date: Tue, 15 Apr 2014 18:16:26 +0800
Subject: [PATCH 0012/1564] fixed #4853:fix bug cc.winSize incorrect when
using setDesignResolutionSize
---
cocos2d/core/platform/CCEGLView.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js
index b9aae0660d..164edf27eb 100644
--- a/cocos2d/core/platform/CCEGLView.js
+++ b/cocos2d/core/platform/CCEGLView.js
@@ -444,10 +444,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
}
// reset director's member variables to fit visible rect
- var director = cc.director;
- director._winSizeInPoints = this.getDesignResolutionSize();
- cc.winSize.width = director._winSizeInPoints.width;
- cc.winSize.height = director._winSizeInPoints.height;
+ cc.winSize.width = _t._visibleRect.width;
+ cc.winSize.height = _t._visibleRect.height;
policy.postApply(this);
From 960318bce89d4c53b512e76f87755d64455d9c61 Mon Sep 17 00:00:00 2001
From: joshua
Date: Wed, 16 Apr 2014 10:16:32 +0800
Subject: [PATCH 0013/1564] fix setDesignResolutionSize bug
---
cocos2d/core/platform/CCEGLView.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js
index 164edf27eb..e8f6989d0f 100644
--- a/cocos2d/core/platform/CCEGLView.js
+++ b/cocos2d/core/platform/CCEGLView.js
@@ -444,8 +444,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
}
// reset director's member variables to fit visible rect
- cc.winSize.width = _t._visibleRect.width;
- cc.winSize.height = _t._visibleRect.height;
+ var director = cc.director;
+ cc.winSize.width = director._winSizeInPoints.width = _t._visibleRect.width;
+ cc.winSize.height = director._winSizeInPoints.height = _t._visibleRect.height;
policy.postApply(this);
From 351f30312c039ba59c5fb832b843a6921a56464a Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Wed, 16 Apr 2014 10:32:51 +0800
Subject: [PATCH 0014/1564] Fixed #4857: Add check to cc._setup to avoid double
invocation
---
CCBoot.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CCBoot.js b/CCBoot.js
index 4d4d2d3cd7..4fb6ae6b63 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -1238,7 +1238,11 @@ cc._rendererInitialized = false;
* // declare like this:
* cc._setup("Cocos2dGameContainer");
*/
+cc._setupCalled = false;
cc._setup = function (el, width, height) {
+ // Avoid setup to be called twice.
+ if (cc._setupCalled) return;
+ else cc._setupCalled = true;
var win = window;
win.requestAnimFrame = win.requestAnimationFrame ||
win.webkitRequestAnimationFrame ||
From 9ec2b51eb640b74914b263df592bf098bf252bb8 Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Wed, 16 Apr 2014 13:06:11 +0800
Subject: [PATCH 0015/1564] Fixed #4670: Null callback check added in Canvas
addImage function
---
cocos2d/core/textures/CCTextureCache.js | 10 ++++------
cocos2d/core/textures/TexturesWebGL.js | 3 +--
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js
index 67d0f964f7..c0494c1026 100644
--- a/cocos2d/core/textures/CCTextureCache.js
+++ b/cocos2d/core/textures/CCTextureCache.js
@@ -327,23 +327,21 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
//remove judge
var tex = locTexs[url] || locTexs[cc.loader._aliases[url]];
if (tex) {
- if (cb)
- cb.call(target);
+ cb && cb.call(target);
return tex;
}
if (!cc.loader.getRes(url)) {
if (cc.loader._checkIsImageURL(url)) {
cc.loader.load(url, function (err) {
- if (cb)
- cb.call(target);
+ cb && cb.call(target);
});
} else {
cc.loader.cache[url] = cc.loader.loadImg(url, function (err, img) {
if (err)
- return cb(err);
+ return cb ? cb(err) : err;
cc.textureCache.handleLoadedTexture(url);
- cb(null, img);
+ cb && cb(null, img);
});
}
}
diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js
index 190b39eee9..b1666db64b 100644
--- a/cocos2d/core/textures/TexturesWebGL.js
+++ b/cocos2d/core/textures/TexturesWebGL.js
@@ -858,8 +858,7 @@ _tmp.WebGLTextureCache = function () {
}
var tex = locTexs[url] || locTexs[cc.loader._aliases[url]];
if (tex) {
- if (cb)
- cb.call(target);
+ cb && cb.call(target);
return tex;
}
From 625c18afb2b6d2eaa116015b39604848a1d26460 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Wed, 16 Apr 2014 16:00:12 +0800
Subject: [PATCH 0016/1564] Closed #4862: Fixed a bug of cc.TMXMapInfo that its
tile property id is wrong
---
cocos2d/tilemap/CCTMXXMLParser.js | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js
index 984d63c562..fd9580b8fc 100644
--- a/cocos2d/tilemap/CCTMXXMLParser.js
+++ b/cocos2d/tilemap/CCTMXXMLParser.js
@@ -630,24 +630,23 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
tileset.sourceImage = this._resources + (this._resources ? "/" : "") + imagename;
}
this.setTilesets(tileset);
- }
- }
- // PARSE
- var tiles = map.querySelectorAll('tile');
- if (tiles) {
- for (i = 0; i < tiles.length; i++) {
- var info = this._tilesets[0];
- var t = tiles[i];
- this.parentGID = parseInt(info.firstGid) + parseInt(t.getAttribute('id') || 0);
- var tp = t.querySelectorAll("properties > property");
- if (tp) {
- var dict = {};
- for (j = 0; j < tp.length; j++) {
- var name = tp[j].getAttribute('name');
- dict[name] = tp[j].getAttribute('value');
+ // PARSE
+ var tiles = selTileset.getElementsByTagName('tile');
+ if (tiles) {
+ for (i = 0; i < tiles.length; i++) {
+ var t = tiles[i];
+ this.parentGID = parseInt(tileset.firstGid) + parseInt(t.getAttribute('id') || 0);
+ var tp = t.querySelectorAll("properties > property");
+ if (tp) {
+ var dict = {};
+ for (j = 0; j < tp.length; j++) {
+ var name = tp[j].getAttribute('name');
+ dict[name] = tp[j].getAttribute('value');
+ }
+ this._tileProperties[this.parentGID] = dict;
+ }
}
- this._tileProperties[this.parentGID] = dict;
}
}
}
From 8587780a4fe5bcb905b7a92970991360ac1896de Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Thu, 17 Apr 2014 09:38:56 +0800
Subject: [PATCH 0017/1564] Closed #4866: Fixed a bug of cc.Scale9Sprite that
its CascadeColor and CascadeOpacity are invalid.
---
extensions/gui/control-extension/CCScale9Sprite.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js
index 3475349b50..291f2998b4 100644
--- a/extensions/gui/control-extension/CCScale9Sprite.js
+++ b/extensions/gui/control-extension/CCScale9Sprite.js
@@ -211,6 +211,8 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
ctor: function () {
cc.NodeRGBA.prototype.ctor.call(this);
+ this._cascadeColorEnabled = true;
+ this._cascadeOpacityEnabled = true;
this._spriteRect = cc.rect(0, 0, 0, 0);
this._capInsetsInternal = cc.rect(0, 0, 0, 0);
@@ -269,6 +271,11 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
this._color.a = opacity;
},
+ updateDisplayedOpacity: function(parentOpacity){
+ cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity);
+ this.setOpacity(this._displayedOpacity);
+ },
+
/** Color: conforms to CCRGBAProtocol protocol */
getColor: function () {
var locColor = this._color;
@@ -295,6 +302,11 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
}
},
+ updateDisplayedColor: function(parentColor){
+ cc.NodeRGBA.prototype.updateDisplayedColor.call(this, parentColor);
+ this.setColor(this._displayedColor);
+ },
+
getCapInsets: function () {
return this._capInsets;
},
From a01abfa9fd242abe13446bf7ce0882e90530d3b4 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Thu, 17 Apr 2014 09:48:31 +0800
Subject: [PATCH 0018/1564] Fixed #4866: remove the test code.
---
extensions/gui/control-extension/CCScale9Sprite.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js
index 291f2998b4..e46564d59d 100644
--- a/extensions/gui/control-extension/CCScale9Sprite.js
+++ b/extensions/gui/control-extension/CCScale9Sprite.js
@@ -211,8 +211,6 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
ctor: function () {
cc.NodeRGBA.prototype.ctor.call(this);
- this._cascadeColorEnabled = true;
- this._cascadeOpacityEnabled = true;
this._spriteRect = cc.rect(0, 0, 0, 0);
this._capInsetsInternal = cc.rect(0, 0, 0, 0);
From fbdbca5a123cbd141b1e306324e724fcf71a8192 Mon Sep 17 00:00:00 2001
From: joshua
Date: Thu, 17 Apr 2014 10:49:50 +0800
Subject: [PATCH 0019/1564] rename constants of Node ,ParticleSystem
---
cocos2d/core/base-nodes/CCNode.js | 8 +-
cocos2d/particle/CCParticleExamples.js | 64 +++---
cocos2d/particle/CCParticleSystem.js | 282 +++++++++++++------------
3 files changed, 181 insertions(+), 173 deletions(-)
diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js
index 8435931689..a9002d7580 100644
--- a/cocos2d/core/base-nodes/CCNode.js
+++ b/cocos2d/core/base-nodes/CCNode.js
@@ -34,12 +34,16 @@ cc.NODE_TAG_INVALID = -1;
* Node on enter
* @constant
*/
-cc.NODE_ON_ENTER = null;
+cc.Node.ON_ENTER = 0;
/**
* Node on exit
* @constant
*/
-cc.NODE_ON_EXIT = null;
+cc.Node.ON_EXIT = 1;
+
+cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
+cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
+cc.Node.ON_CLEAN_UP = 4;
/**
* XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered.
diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js
index 06d5cf793c..962d4b7fc4 100644
--- a/cocos2d/particle/CCParticleExamples.js
+++ b/cocos2d/particle/CCParticleExamples.js
@@ -49,10 +49,10 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
@@ -83,7 +83,7 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{
// size, in pixels
this.setStartSize(54.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per frame
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -142,10 +142,10 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks#
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, -90));
@@ -182,7 +182,7 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks#
// size, in pixels
this.setStartSize(8.0);
this.setStartSizeVar(2.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// additive
this.setBlendAdditive(false);
@@ -235,10 +235,10 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{
this.setBlendAdditive(true);
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -267,7 +267,7 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{
// size, in pixels
this.setStartSize(30.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per seconds
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -326,10 +326,10 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -362,7 +362,7 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{
// size, in pixels
this.setStartSize(37.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -420,10 +420,10 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -456,7 +456,7 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{
// size, in pixels
this.setStartSize(30.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -516,10 +516,10 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(-200, 200));
@@ -552,7 +552,7 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{
// size, in pixels
this.setStartSize(60.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -611,10 +611,10 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -647,7 +647,7 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{
// size, in pixels
this.setStartSize(20.0);
this.setStartSizeVar(0.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -709,7 +709,7 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion#
// duration
this.setDuration(0.1);
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -742,7 +742,7 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion#
// size, in pixels
this.setStartSize(15.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(this.getTotalParticles() / this.getDuration());
@@ -802,10 +802,10 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// Emitter mode: Gravity Mode
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, 0));
@@ -834,7 +834,7 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{
// size, in pixels
this.setStartSize(60.0);
this.setStartSizeVar(10.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per frame
this.setEmissionRate(this.getTotalParticles() / this.getLife());
@@ -893,10 +893,10 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
// set gravity mode.
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(0, -1));
@@ -929,7 +929,7 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{
// size, in pixels
this.setStartSize(10.0);
this.setStartSizeVar(5.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(10);
@@ -989,9 +989,9 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{
initWithTotalParticles:function (numberOfParticles) {
if (cc.ParticleSystem.prototype.initWithTotalParticles.call(this, numberOfParticles)) {
// duration
- this.setDuration(cc.PARTICLE_DURATION_INFINITY);
+ this.setDuration(cc.ParticleSystem.DURATION_INFINITY);
- this.setEmitterMode(cc.PARTICLE_MODE_GRAVITY);
+ this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY);
// Gravity Mode: gravity
this.setGravity(cc.p(10, -10));
@@ -1025,7 +1025,7 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{
// size, in pixels
this.setStartSize(4.0);
this.setStartSizeVar(2.0);
- this.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE);
+ this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE);
// emits per second
this.setEmissionRate(20);
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index 8607313689..7e5ddded0a 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -41,91 +41,10 @@
// cocos2d uses a another approach, but the results are almost identical.
//
-/**
- * Shape Mode of Particle Draw
- * @constant
- * @type Number
- */
-cc.PARTICLE_SHAPE_MODE = 0;
-/**
- * Texture Mode of Particle Draw
- * @constant
- * @type Number
- */
-cc.PARTICLE_TEXTURE_MODE = 1;
-
-/**
- * Star Shape for ShapeMode of Particle
- * @constant
- * @type Number
- */
-cc.PARTICLE_STAR_SHAPE = 0;
-/**
- * Ball Shape for ShapeMode of Particle
- * @constant
- * @type Number
- */
-cc.PARTICLE_BALL_SHAPE = 1;
-
-/**
- * The Particle emitter lives forever
- * @constant
- * @type Number
- */
-cc.PARTICLE_DURATION_INFINITY = -1;
-
-/**
- * The starting size of the particle is equal to the ending size
- * @constant
- * @type Number
- */
-cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1;
-
-/**
- * The starting radius of the particle is equal to the ending radius
- * @constant
- * @type Number
- */
-cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1;
-
-/**
- * Gravity mode (A mode)
- * @constant
- * @type Number
- */
-cc.PARTICLE_MODE_GRAVITY = 0;
-
-/**
- * Radius mode (B mode)
- * @constant
- * @type Number
- */
-cc.PARTICLE_MODE_RADIUS = 1;
// tCCPositionType
// possible types of particle positions
-/**
- * Living particles are attached to the world and are unaffected by emitter repositioning.
- * @constant
- * @type Number
- */
-cc.PARTICLE_TYPE_FREE = 0;
-
-/**
- * Living particles are attached to the world but will follow the emitter repositioning.
- * Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
- * @constant
- * @type Number
- */
-cc.PARTICLE_TYPE_RELATIVE = 1;
-
-/**
- * Living particles are attached to the emitter and are translated along with it.
- * @constant
- * @type Number
- */
-cc.PARTICLE_TYPE_GROUPED = 2;
/**
* Structure that contains the values of each particle
@@ -244,7 +163,7 @@ cc.Particle.TemporaryPoints = [
* @property {Boolean} opacityModifyRGB - Indicate whether the alpha value modify color.
* @property {cc.SpriteBatchNode} batchNode - Weak reference to the sprite batch node.
* @property {Boolean} active - <@readonly> Indicate whether the particle system is activated.
- * @property {Number} shapeType - ShapeType of ParticleSystem : cc.PARTICLE_BALL_SHAPE | cc.PARTICLE_STAR_SHAPE.
+ * @property {Number} shapeType - ShapeType of ParticleSystem : cc.ParticleSystem.BALL_SHAPE | cc.ParticleSystem.STAR_SHAPE.
* @property {Number} atlasIndex - Index of system in batch node array.
* @property {Number} particleCount - Current quantity of particles that are being simulated.
* @property {Number} duration - How many seconds the emitter wil run. -1 means 'forever'
@@ -281,8 +200,8 @@ cc.Particle.TemporaryPoints = [
* @property {cc.Color} endColor - Ending color of each particle.
* @property {cc.Color} endColorVar - Variation of the end color.
* @property {Number} emissionRate - Emission rate of the particles.
- * @property {Number} emitterMode - Emitter modes: CCPARTICLE_MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration; CCPARTICLE_MODE_RADIUS: uses radius movement + rotation.
- * @property {Number} positionType - Particles movement type: cc.PARTICLE_TYPE_FREE | cc.PARTICLE_TYPE_GROUPED.
+ * @property {Number} emitterMode - Emitter modes: CCParticleSystem.MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration; CCParticleSystem.MODE_RADIUS: uses radius movement + rotation.
+ * @property {Number} positionType - Particles movement type: cc.ParticleSystem.TYPE_FREE | cc.ParticleSystem.TYPE_GROUPED.
* @property {Number} totalParticles - Maximum particles of the system.
* @property {Boolean} autoRemoveOnFinish - Indicate whether the node will be auto-removed when it has no particles left.
* @property {cc.Texture2D} texture - Texture of Particle System.
@@ -328,10 +247,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
_allocatedParticles: 0,
//drawMode
- drawMode: cc.PARTICLE_SHAPE_MODE,
+ drawMode: cc.ParticleSystem.SHAPE_MODE,
//shape type
- shapeType: cc.PARTICLE_BALL_SHAPE,
+ shapeType: cc.ParticleSystem.BALL_SHAPE,
_isActive: false,
particleCount: 0,
duration: 0,
@@ -358,7 +277,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
_texture: null,
_blendFunc: null,
_opacityModifyRGB: false,
- positionType: cc.PARTICLE_TYPE_FREE,
+ positionType: cc.ParticleSystem.TYPE_FREE,
autoRemoveOnFinish: false,
emitterMode: 0,
@@ -385,7 +304,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
*/
ctor:function (plistFile) {
cc.Node.prototype.ctor.call(this);
- this.emitterMode = cc.PARTICLE_MODE_GRAVITY;
+ this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
this.modeA = new cc.ParticleSystem.ModeA();
this.modeB = new cc.ParticleSystem.ModeB();
this._blendFunc = {src:cc.BLEND_SRC, dst:cc.BLEND_DST};
@@ -410,8 +329,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
this._transformSystemDirty = false;
this._allocatedParticles = 0;
- this.drawMode = cc.PARTICLE_SHAPE_MODE;
- this.shapeType = cc.PARTICLE_BALL_SHAPE;
+ this.drawMode = cc.ParticleSystem.SHAPE_MODE;
+ this.shapeType = cc.ParticleSystem.BALL_SHAPE;
this._isActive = false;
this.particleCount = 0;
this.duration = 0;
@@ -432,7 +351,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
this._totalParticles = 0;
this._texture = null;
this._opacityModifyRGB = false;
- this.positionType = cc.PARTICLE_TYPE_FREE;
+ this.positionType = cc.ParticleSystem.TYPE_FREE;
this.autoRemoveOnFinish = false;
this._buffersVBO = [0, 0];
@@ -447,7 +366,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
if (!plistFile || typeof(plistFile) === "number") {
var ton = plistFile || 100;
- this.setDrawMode(cc.PARTICLE_TEXTURE_MODE);
+ this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE);
this.initWithTotalParticles(ton);
}else{
this.initWithFile(plistFile);
@@ -785,7 +704,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {cc.Point}
*/
getGravity:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");
var locGravity = this.modeA.gravity;
return cc.p(locGravity.x, locGravity.y);
@@ -796,7 +715,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {cc.Point} gravity
*/
setGravity:function (gravity) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");
this.modeA.gravity = gravity;
},
@@ -806,7 +725,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getSpeed:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");
return this.modeA.speed;
},
@@ -816,7 +735,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} speed
*/
setSpeed:function (speed) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");
this.modeA.speed = speed;
},
@@ -826,7 +745,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getSpeedVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");
return this.modeA.speedVar;
},
@@ -836,7 +755,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} speedVar
*/
setSpeedVar:function (speedVar) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
this.modeA.speedVar = speedVar;
},
@@ -846,7 +765,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getTangentialAccel:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");
return this.modeA.tangentialAccel;
},
@@ -856,7 +775,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} tangentialAccel
*/
setTangentialAccel:function (tangentialAccel) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");
this.modeA.tangentialAccel = tangentialAccel;
},
@@ -866,7 +785,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getTangentialAccelVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");
return this.modeA.tangentialAccelVar;
},
@@ -876,7 +795,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} tangentialAccelVar
*/
setTangentialAccelVar:function (tangentialAccelVar) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");
this.modeA.tangentialAccelVar = tangentialAccelVar;
},
@@ -886,7 +805,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getRadialAccel:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");
return this.modeA.radialAccel;
},
@@ -896,7 +815,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} radialAccel
*/
setRadialAccel:function (radialAccel) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");
this.modeA.radialAccel = radialAccel;
},
@@ -906,7 +825,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getRadialAccelVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");
return this.modeA.radialAccelVar;
},
@@ -916,7 +835,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} radialAccelVar
*/
setRadialAccelVar:function (radialAccelVar) {
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
this.modeA.radialAccelVar = radialAccelVar;
},
@@ -926,7 +845,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @returns {boolean}
*/
getRotationIsDir: function(){
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");
return this.modeA.rotationIsDir;
},
@@ -936,7 +855,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {boolean} t
*/
setRotationIsDir: function(t){
- if(this.emitterMode !== cc.PARTICLE_MODE_GRAVITY)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");
this.modeA.rotationIsDir = t;
},
@@ -947,7 +866,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getStartRadius:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
return this.modeB.startRadius;
},
@@ -957,7 +876,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} startRadius
*/
setStartRadius:function (startRadius) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");
this.modeB.startRadius = startRadius;
},
@@ -967,7 +886,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getStartRadiusVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");
return this.modeB.startRadiusVar;
},
@@ -977,7 +896,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} startRadiusVar
*/
setStartRadiusVar:function (startRadiusVar) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
this.modeB.startRadiusVar = startRadiusVar;
},
@@ -987,7 +906,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getEndRadius:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");
return this.modeB.endRadius;
},
@@ -997,7 +916,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} endRadius
*/
setEndRadius:function (endRadius) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");
this.modeB.endRadius = endRadius;
},
@@ -1007,7 +926,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getEndRadiusVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
return this.modeB.endRadiusVar;
},
@@ -1017,7 +936,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param endRadiusVar
*/
setEndRadiusVar:function (endRadiusVar) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");
this.modeB.endRadiusVar = endRadiusVar;
},
@@ -1027,7 +946,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getRotatePerSecond:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");
return this.modeB.rotatePerSecond;
},
@@ -1037,7 +956,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param {Number} degrees
*/
setRotatePerSecond:function (degrees) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
this.modeB.rotatePerSecond = degrees;
},
@@ -1047,7 +966,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @return {Number}
*/
getRotatePerSecondVar:function () {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");
return this.modeB.rotatePerSecondVar;
},
@@ -1057,7 +976,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
* @param degrees
*/
setRotatePerSecondVar:function (degrees) {
- if(this.emitterMode !== cc.PARTICLE_MODE_RADIUS)
+ if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");
this.modeB.rotatePerSecondVar = degrees;
},
@@ -1508,8 +1427,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
/**
* Switch between different kind of emitter modes:
- * - CCPARTICLE_MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration
- * - CCPARTICLE_MODE_RADIUS: uses radius movement + rotation
+ * - CCParticleSystem.MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration
+ * - CCParticleSystem.MODE_RADIUS: uses radius movement + rotation
*
* @param {Number} emitterMode
*/
@@ -1625,7 +1544,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
this.emitterMode = parseInt(locValueForKey("emitterType", dictionary));
// Mode A: Gravity + tangential accel + radial accel
- if (this.emitterMode == cc.PARTICLE_MODE_GRAVITY) {
+ if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
var locModeA = this.modeA;
// gravity
locModeA.gravity.x = parseFloat(locValueForKey("gravityx", dictionary));
@@ -1652,7 +1571,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
// rotation is dir
var locRotationIsDir = locValueForKey("rotationIsDir", dictionary).toLowerCase();
locModeA.rotationIsDir = (locRotationIsDir != null && (locRotationIsDir === "true" || locRotationIsDir === "1"));
- } else if (this.emitterMode == cc.PARTICLE_MODE_RADIUS) {
+ } else if (this.emitterMode == cc.ParticleSystem.MODE_RADIUS) {
// or Mode B: radius movement
var locModeB = this.modeB;
locModeB.startRadius = parseFloat(locValueForKey("maxRadius", dictionary));
@@ -1763,10 +1682,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
this._blendFunc.dst = cc.BLEND_DST;
// default movement type;
- this.positionType = cc.PARTICLE_TYPE_FREE;
+ this.positionType = cc.ParticleSystem.TYPE_FREE;
// by default be in mode A:
- this.emitterMode = cc.PARTICLE_MODE_GRAVITY;
+ this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
// default: modulate
// XXX: not used
@@ -1882,7 +1801,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
startS = Math.max(0, startS); // No negative value
particle.size = startS;
- if (this.endSize === cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) {
+ if (this.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE) {
particle.deltaSize = 0;
} else {
var endS = this.endSize + this.endSizeVar * locRandomMinus11();
@@ -1897,9 +1816,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
particle.deltaRotation = (endA - startA) / locParticleTimeToLive;
// position
- if (this.positionType == cc.PARTICLE_TYPE_FREE)
+ if (this.positionType == cc.ParticleSystem.TYPE_FREE)
particle.startPos = this.convertToWorldSpace(this._pointZeroForParticle);
- else if (this.positionType == cc.PARTICLE_TYPE_RELATIVE){
+ else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE){
particle.startPos.x = this._position.x;
particle.startPos.y = this._position.y;
}
@@ -1908,7 +1827,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
var a = cc.degreesToRadians(this.angle + this.angleVar * locRandomMinus11());
// Mode Gravity: A
- if (this.emitterMode === cc.PARTICLE_MODE_GRAVITY) {
+ if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) {
var locModeA = this.modeA, locParticleModeA = particle.modeA;
var s = locModeA.speed + locModeA.speedVar * locRandomMinus11();
@@ -1935,7 +1854,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
var endRadius = locModeB.endRadius + locModeB.endRadiusVar * locRandomMinus11();
locParitlceModeB.radius = startRadius;
- locParitlceModeB.deltaRadius = (locModeB.endRadius === cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS) ? 0 : (endRadius - startRadius) / locParticleTimeToLive;
+ locParitlceModeB.deltaRadius = (locModeB.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS) ? 0 : (endRadius - startRadius) / locParticleTimeToLive;
locParitlceModeB.angle = a;
locParitlceModeB.degreesPerSecond = cc.degreesToRadians(locModeB.rotatePerSecond + locModeB.rotatePerSecondVar * locRandomMinus11());
@@ -2124,9 +2043,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
this._particleIdx = 0;
var currentPosition = cc.Particle.TemporaryPoints[0];
- if (this.positionType == cc.PARTICLE_TYPE_FREE) {
+ if (this.positionType == cc.ParticleSystem.TYPE_FREE) {
cc.pIn(currentPosition, this.convertToWorldSpace(this._pointZeroForParticle));
- } else if (this.positionType == cc.PARTICLE_TYPE_RELATIVE) {
+ } else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE) {
currentPosition.x = this._position.x;
currentPosition.y = this._position.y;
}
@@ -2153,7 +2072,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
if (selParticle.timeToLive > 0) {
// Mode A: gravity, direction, tangential accel & radial accel
- if (this.emitterMode == cc.PARTICLE_MODE_GRAVITY) {
+ if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
var tmp = tpc, radial = tpa, tangential = tpb;
@@ -2217,7 +2136,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
// update values in quad
//
var newPos = tpa;
- if (this.positionType == cc.PARTICLE_TYPE_FREE || this.positionType == cc.PARTICLE_TYPE_RELATIVE) {
+ if (this.positionType == cc.ParticleSystem.TYPE_FREE || this.positionType == cc.ParticleSystem.TYPE_RELATIVE) {
var diff = tpb;
cc.pIn(diff, currentPosition);
@@ -2382,7 +2301,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
retParticle.emitterMode = this.emitterMode;
// Mode A: Gravity + tangential accel + radial accel
- if (this.emitterMode == cc.PARTICLE_MODE_GRAVITY) {
+ if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
var particleModeA = retParticle.modeA, locModeA = this.modeA;
// gravity
particleModeA.gravity.x = locModeA.gravity.x;
@@ -2401,7 +2320,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
particleModeA.tangentialAccel = locModeA.tangentialAccel;
particleModeA.tangentialAccelVar = locModeA.tangentialAccelVar;
- } else if (this.emitterMode == cc.PARTICLE_MODE_RADIUS) {
+ } else if (this.emitterMode == cc.ParticleSystem.MODE_RADIUS) {
var particleModeB = retParticle.modeB, locModeB = this.modeB;
// or Mode B: radius movement
particleModeB.startRadius = locModeB.startRadius;
@@ -2501,7 +2420,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
var particle = this._particles[i];
var lpx = (0 | (particle.size * 0.5));
- if (this.drawMode == cc.PARTICLE_TEXTURE_MODE) {
+ if (this.drawMode == cc.ParticleSystem.TEXTURE_MODE) {
var element = this._texture.getHtmlElementObj();
@@ -2552,7 +2471,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y));
- if (this.shapeType == cc.PARTICLE_STAR_SHAPE) {
+ if (this.shapeType == cc.ParticleSystem.STAR_SHAPE) {
if (particle.rotation)
context.rotate(cc.degreesToRadians(particle.rotation));
cc._drawingUtil.drawStar(context, lpx, particle.color);
@@ -2838,3 +2757,88 @@ cc.ParticleSystem.ModeB = function (startRadius, startRadiusVar, endRadius, endR
/** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */
this.rotatePerSecondVar = rotatePerSecondVar || 0;
};
+
+/**
+ * Shape Mode of Particle Draw
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.SHAPE_MODE = 0;
+
+/**
+ * Texture Mode of Particle Draw
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.TEXTURE_MODE = 1;
+
+/**
+ * Star Shape for ShapeMode of Particle
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.STAR_SHAPE = 0;
+
+/**
+ * Ball Shape for ShapeMode of Particle
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.BALL_SHAPE = 1;
+
+/**
+ * The Particle emitter lives forever
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.DURATION_INFINITY = -1;
+
+/**
+ * The starting size of the particle is equal to the ending size
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
+
+/**
+ * The starting radius of the particle is equal to the ending radius
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
+
+/**
+ * Gravity mode (A mode)
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.MODE_GRAVITY = 0;
+
+/**
+ * Radius mode (B mode)
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.MODE_RADIUS = 1;
+
+/**
+ * Living particles are attached to the world and are unaffected by emitter repositioning.
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.TYPE_FREE = 0;
+
+/**
+ * Living particles are attached to the world but will follow the emitter repositioning.
+ * Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.TYPE_RELATIVE = 1;
+
+/**
+ * Living particles are attached to the emitter and are translated along with it.
+ * @constant
+ * @type Number
+ */
+cc.ParticleSystem.TYPE_GROUPED = 2;
\ No newline at end of file
From 1319d489b99fe52573cbbe9a633d644d44fda353 Mon Sep 17 00:00:00 2001
From: joshua
Date: Thu, 17 Apr 2014 11:40:29 +0800
Subject: [PATCH 0020/1564] fix position of Node's constants
---
cocos2d/core/base-nodes/CCNode.js | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js
index a9002d7580..b42094b4fe 100644
--- a/cocos2d/core/base-nodes/CCNode.js
+++ b/cocos2d/core/base-nodes/CCNode.js
@@ -30,20 +30,6 @@
* @type Number
*/
cc.NODE_TAG_INVALID = -1;
-/**
- * Node on enter
- * @constant
- */
-cc.Node.ON_ENTER = 0;
-/**
- * Node on exit
- * @constant
- */
-cc.Node.ON_EXIT = 1;
-
-cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
-cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
-cc.Node.ON_CLEAN_UP = 4;
/**
* XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered.
@@ -2482,4 +2468,19 @@ cc.NodeRGBA.create = function () {
};
_tmp.PrototypeCCNodeRGBA();
-delete _tmp.PrototypeCCNodeRGBA;
\ No newline at end of file
+delete _tmp.PrototypeCCNodeRGBA;
+
+/**
+ * Node on enter
+ * @constant
+ */
+cc.Node.ON_ENTER = 0;
+/**
+ * Node on exit
+ * @constant
+ */
+cc.Node.ON_EXIT = 1;
+
+cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
+cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
+cc.Node.ON_CLEAN_UP = 4;
\ No newline at end of file
From 7c27837adffbb81b5cab8f6590b2028fb8b563cd Mon Sep 17 00:00:00 2001
From: joshua
Date: Thu, 17 Apr 2014 14:55:51 +0800
Subject: [PATCH 0021/1564] rename constants of
ProgressTimer,Scale9Sprite,TMXLayerInfo
---
cocos2d/progress-timer/CCProgressTimer.js | 84 +++++++++----------
cocos2d/tilemap/CCTMXXMLParser.js | 47 ++++++-----
cocos2d/transitions/CCTransitionProgress.js | 12 +--
.../gui/control-extension/CCScale9Sprite.js | 62 +++++++-------
4 files changed, 102 insertions(+), 103 deletions(-)
diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js
index ee35370fea..832031c6e2 100644
--- a/cocos2d/progress-timer/CCProgressTimer.js
+++ b/cocos2d/progress-timer/CCProgressTimer.js
@@ -23,32 +23,6 @@
THE SOFTWARE.
****************************************************************************/
-
-/**
- * Radial Counter-Clockwise
- * @type Number
- * @constant
- */
-cc.PROGRESS_TIMER_TYPE_RADIAL = 0;
-/**
- * Bar
- * @type Number
- * @constant
- */
-cc.PROGRESS_TIMER_TYPE_BAR = 1;
-
-/**
- * @constant
- * @type Number
- */
-cc.PROGRESS_TEXTURE_COORDS_COUNT = 4;
-
-/**
- * @constant
- * @type Number
- */
-cc.PROGRESS_TEXTURE_COORDS = 0x4b;
-
/**
* cc.Progresstimer is a subclass of cc.Node.
* It renders the inner sprite according to the percentage.
@@ -65,7 +39,7 @@ cc.PROGRESS_TEXTURE_COORDS = 0x4b;
* you want a bottom to top then set the midpoint all the way to cc.p(x,0)
* you want a top to bottom then set the midpoint all the way to cc.p(x,1)
* @property {cc.Point} barChangeRate - This allows the bar type to move the component at a specific rate.
- * @property {enum} type - Type of the progress timer: cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR.
+ * @property {enum} type - Type of the progress timer: cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR.
* @property {Number} percentage - Percentage to change progress, from 0 to 100.
* @property {cc.Sprite} sprite - The sprite to show the progress percentage.
* @property {Boolean} reverseDir - Indicate whether the direction is reversed.
@@ -123,7 +97,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
/**
* Change the percentage to change progress
- * @return {cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR}
+ * @return {cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR}
*/
getType:function () {
return this._type;
@@ -168,8 +142,8 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
},
_boundaryTexCoord:function (index) {
- if (index < cc.PROGRESS_TEXTURE_COORDS_COUNT) {
- var locProTextCoords = cc.PROGRESS_TEXTURE_COORDS;
+ if (index < cc.ProgressTimer.TEXTURE_COORDS_COUNT) {
+ var locProTextCoords = cc.ProgressTimer.TEXTURE_COORDS;
if (this._reverseDirection)
return cc.p((locProTextCoords >> (7 - (index << 1))) & 1, (locProTextCoords >> (7 - ((index << 1) + 1))) & 1);
else
@@ -196,7 +170,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
_ctorForCanvas: function () {
cc.NodeRGBA.prototype.ctor.call(this);
- this._type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ this._type = cc.ProgressTimer.TYPE_RADIAL;
this._percentage = 0.0;
this._midPoint = cc.p(0, 0);
this._barChangeRate = cc.p(0, 0);
@@ -214,7 +188,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
_ctorForWebGL: function () {
cc.NodeRGBA.prototype.ctor.call(this);
- this._type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ this._type = cc.ProgressTimer.TYPE_RADIAL;
this._percentage = 0.0;
this._midPoint = cc.p(0, 0);
this._barChangeRate = cc.p(0, 0);
@@ -317,7 +291,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
/**
* set Progress type of cc.ProgressTimer
* @function
- * @param {cc.PROGRESS_TIMER_TYPE_RADIAL|cc.PROGRESS_TIMER_TYPE_BAR} type
+ * @param {cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR} type
*/
setType:null,
@@ -406,7 +380,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
this.anchorX = 0.5;
this.anchorY = 0.5;
- this._type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ this._type = cc.ProgressTimer.TYPE_RADIAL;
this._reverseDirection = false;
this.midPoint = cc.p(0.5, 0.5);
this.barChangeRate = cc.p(1, 1);
@@ -423,7 +397,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
this.anchorX = 0.5;
this.anchorY = 0.5;
- this._type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ this._type = cc.ProgressTimer.TYPE_RADIAL;
this._reverseDirection = false;
this.midPoint = cc.p(0.5, 0.5);
this.barChangeRate = cc.p(1, 1);
@@ -470,13 +444,13 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
flipYOffset *= locEGL_ScaleY;
//clip
- if (this._type == cc.PROGRESS_TIMER_TYPE_BAR) {
+ if (this._type == cc.ProgressTimer.TYPE_BAR) {
var locBarRect = this._barRect;
context.beginPath();
context.rect(locBarRect.x * locEGL_ScaleX, locBarRect.y * locEGL_ScaleY, locBarRect.width * locEGL_ScaleX, locBarRect.height * locEGL_ScaleY);
context.clip();
context.closePath();
- } else if (this._type == cc.PROGRESS_TIMER_TYPE_RADIAL) {
+ } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) {
var locOriginX = this._origin.x * locEGL_ScaleX;
var locOriginY = this._origin.y * locEGL_ScaleY;
context.beginPath();
@@ -531,9 +505,9 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, locVertexDataLen, 8);
context.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, context.FLOAT, false, locVertexDataLen, 12);
- if (this._type === cc.PROGRESS_TIMER_TYPE_RADIAL)
+ if (this._type === cc.ProgressTimer.TYPE_RADIAL)
context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount);
- else if (this._type == cc.PROGRESS_TIMER_TYPE_BAR) {
+ else if (this._type == cc.ProgressTimer.TYPE_BAR) {
if (!this._reverseDirection)
context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount);
else {
@@ -590,7 +564,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
// We loop through five points since the top is split in half
var min_t = cc.FLT_MAX;
- var locProTextCoordsCount = cc.PROGRESS_TEXTURE_COORDS_COUNT;
+ var locProTextCoordsCount = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
for (i = 0; i <= locProTextCoordsCount; ++i) {
var pIndex = (i + (locProTextCoordsCount - 1)) % locProTextCoordsCount;
@@ -814,7 +788,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
var sw = locSprite.width, sh = locSprite.height;
var locMidPoint = this._midPoint;
- if (this._type == cc.PROGRESS_TIMER_TYPE_RADIAL) {
+ if (this._type == cc.ProgressTimer.TYPE_RADIAL) {
this._radius = Math.round(Math.sqrt(sw * sw + sh * sh));
var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = this._origin;
locOrigin.x = sw * locMidPoint.x;
@@ -901,9 +875,9 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{
_updateProgressForWebGL:function () {
var locType = this._type;
- if(locType === cc.PROGRESS_TIMER_TYPE_RADIAL)
+ if(locType === cc.ProgressTimer.TYPE_RADIAL)
this._updateRadial();
- else if(locType === cc.PROGRESS_TIMER_TYPE_BAR)
+ else if(locType === cc.ProgressTimer.TYPE_BAR)
this._updateBar();
this._vertexDataDirty = true;
}
@@ -966,4 +940,28 @@ cc.ProgressTimer.create = function (sprite) {
return null;
};
+/**
+ * @constant
+ * @type Number
+ */
+cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4;
+/**
+ * @constant
+ * @type Number
+ */
+cc.ProgressTimer.TEXTURE_COORDS = 0x4b;
+
+/**
+ * Radial Counter-Clockwise
+ * @type Number
+ * @constant
+ */
+cc.ProgressTimer.TYPE_RADIAL = 0;
+
+/**
+ * Bar
+ * @type Number
+ * @constant
+ */
+cc.ProgressTimer.TYPE_BAR = 1;
diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js
index fd9580b8fc..235db4772d 100644
--- a/cocos2d/tilemap/CCTMXXMLParser.js
+++ b/cocos2d/tilemap/CCTMXXMLParser.js
@@ -24,27 +24,6 @@
THE SOFTWARE.
****************************************************************************/
-/**
- * @constant
- * @type Number
- */
-cc.TMX_LAYER_ATTRIB_NONE = 1 << 0;
-/**
- * @constant
- * @type Number
- */
-cc.TMX_LAYER_ATTRIB_BASE64 = 1 << 1;
-/**
- * @constant
- * @type Number
- */
-cc.TMX_LAYER_ATTRIB_GZIP = 1 << 2;
-/**
- * @constant
- * @type Number
- */
-cc.TMX_LAYER_ATTRIB_ZLIB = 1 << 3;
-
/**
* @constant
* @type Number
@@ -717,7 +696,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
}
break;
default:
- if(this.layerAttrs == cc.TMX_LAYER_ATTRIB_NONE)
+ if(this.layerAttrs == cc.TMXLayerInfo.ATTRIB_NONE)
cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported");
break;
}
@@ -890,7 +869,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
// tmp vars
this.currentString = "";
this.storingCharacters = false;
- this.layerAttrs = cc.TMX_LAYER_ATTRIB_NONE;
+ this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
this.parentElement = cc.TMX_PROPERTY_NONE;
this._currentFirstGID = 0;
}
@@ -935,3 +914,25 @@ cc.TMXMapInfo.create = function (tmxFile, resourcePath) {
cc.loader.register(["tmx", "tsx"], cc._txtLoader);
+
+
+/**
+ * @constant
+ * @type Number
+ */
+cc.TMXLayerInfo.ATTRIB_NONE = 1 << 0;
+/**
+ * @constant
+ * @type Number
+ */
+cc.TMXLayerInfo.ATTRIB_BASE64 = 1 << 1;
+/**
+ * @constant
+ * @type Number
+ */
+cc.TMXLayerInfo.ATTRIB_GZIP = 1 << 2;
+/**
+ * @constant
+ * @type Number
+ */
+cc.TMXLayerInfo.ATTRIB_ZLIB = 1 << 3;
diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js
index 275163c22e..988365fdf0 100644
--- a/cocos2d/transitions/CCTransitionProgress.js
+++ b/cocos2d/transitions/CCTransitionProgress.js
@@ -147,7 +147,7 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ pNode.type = cc.ProgressTimer.TYPE_RADIAL;
// Return the radial type that we want to use
pNode.reverseDir = false;
@@ -188,7 +188,7 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_RADIAL;
+ pNode.type = cc.ProgressTimer.TYPE_RADIAL;
// Return the radial type that we want to use
pNode.reverseDir = true;
@@ -229,7 +229,7 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_BAR;
+ pNode.type = cc.ProgressTimer.TYPE_BAR;
pNode.midPoint = cc.p(1, 0);
pNode.barChangeRate = cc.p(1, 0);
@@ -270,7 +270,7 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_BAR;
+ pNode.type = cc.ProgressTimer.TYPE_BAR;
pNode.midPoint = cc.p(0, 0);
pNode.barChangeRate = cc.p(0, 1);
@@ -310,7 +310,7 @@ cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.Transiti
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_BAR;
+ pNode.type = cc.ProgressTimer.TYPE_BAR;
pNode.midPoint = cc.p(0.5, 0.5);
pNode.barChangeRate = cc.p(1, 1);
@@ -358,7 +358,7 @@ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.Transiti
// but it is flipped upside down so we flip the sprite
if (cc._renderType === cc._RENDER_TYPE_WEBGL)
pNode.sprite.flippedY = true;
- pNode.type = cc.PROGRESS_TIMER_TYPE_BAR;
+ pNode.type = cc.ProgressTimer.TYPE_BAR;
pNode.midPoint = cc.p(0.5, 0.5);
pNode.barChangeRate = cc.p(1, 1);
diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js
index 3475349b50..2cb7b9754c 100644
--- a/extensions/gui/control-extension/CCScale9Sprite.js
+++ b/extensions/gui/control-extension/CCScale9Sprite.js
@@ -25,19 +25,6 @@
Created by Jung Sang-Taik on 2012-03-16
****************************************************************************/
-/**
- * @ignore
- */
-cc.POSITIONS_CENTRE = 0;
-cc.POSITIONS_TOP = 1;
-cc.POSITIONS_LEFT = 2;
-cc.POSITIONS_RIGHT = 3;
-cc.POSITIONS_BOTTOM = 4;
-cc.POSITIONS_TOPRIGHT = 5;
-cc.POSITIONS_TOPLEFT = 6;
-cc.POSITIONS_BOTTOMRIGHT = 7;
-cc.POSITIONS_BOTTOMLEFT = 8;
-
/**
* A 9-slice sprite for cocos2d.
*
@@ -720,47 +707,47 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
// Centre
this._centre = new cc.Sprite();
this._centre.initWithTexture(selTexture, centerbounds);
- locScale9Image.addChild(this._centre, 0, cc.POSITIONS_CENTRE);
+ locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
// Top
this._top = new cc.Sprite();
this._top.initWithTexture(selTexture, centertopbounds);
- locScale9Image.addChild(this._top, 1, cc.POSITIONS_TOP);
+ locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
// Bottom
this._bottom = new cc.Sprite();
this._bottom.initWithTexture(selTexture, centerbottombounds);
- locScale9Image.addChild(this._bottom, 1, cc.POSITIONS_BOTTOM);
+ locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
// Left
this._left = new cc.Sprite();
this._left.initWithTexture(selTexture, leftcenterbounds);
- locScale9Image.addChild(this._left, 1, cc.POSITIONS_LEFT);
+ locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
// Right
this._right = new cc.Sprite();
this._right.initWithTexture(selTexture, rightcenterbounds);
- locScale9Image.addChild(this._right, 1, cc.POSITIONS_RIGHT);
+ locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
// Top left
this._topLeft = new cc.Sprite();
this._topLeft.initWithTexture(selTexture, lefttopbounds);
- locScale9Image.addChild(this._topLeft, 2, cc.POSITIONS_TOPLEFT);
+ locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
// Top right
this._topRight = new cc.Sprite();
this._topRight.initWithTexture(selTexture, righttopbounds);
- locScale9Image.addChild(this._topRight, 2, cc.POSITIONS_TOPRIGHT);
+ locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
// Bottom left
this._bottomLeft = new cc.Sprite();
this._bottomLeft.initWithTexture(selTexture, leftbottombounds);
- locScale9Image.addChild(this._bottomLeft, 2, cc.POSITIONS_BOTTOMLEFT);
+ locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
// Bottom right
this._bottomRight = new cc.Sprite();
this._bottomRight.initWithTexture(selTexture, rightbottombounds);
- locScale9Image.addChild(this._bottomRight, 2, cc.POSITIONS_BOTTOMRIGHT);
+ locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
} else {
// set up transformation of coordinates
// to handle the case where the sprite is stored rotated
@@ -819,47 +806,47 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{
// Centre
this._centre = new cc.Sprite();
this._centre.initWithTexture(selTexture, rotatedcenterbounds, true);
- locScale9Image.addChild(this._centre, 0, cc.POSITIONS_CENTRE);
+ locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
// Top
this._top = new cc.Sprite();
this._top.initWithTexture(selTexture, rotatedcentertopbounds, true);
- locScale9Image.addChild(this._top, 1, cc.POSITIONS_TOP);
+ locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
// Bottom
this._bottom = new cc.Sprite();
this._bottom.initWithTexture(selTexture, rotatedcenterbottombounds, true);
- locScale9Image.addChild(this._bottom, 1, cc.POSITIONS_BOTTOM);
+ locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
// Left
this._left = new cc.Sprite();
this._left.initWithTexture(selTexture, rotatedleftcenterbounds, true);
- locScale9Image.addChild(this._left, 1, cc.POSITIONS_LEFT);
+ locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
// Right
this._right = new cc.Sprite();
this._right.initWithTexture(selTexture, rotatedrightcenterbounds, true);
- locScale9Image.addChild(this._right, 1, cc.POSITIONS_RIGHT);
+ locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
// Top left
this._topLeft = new cc.Sprite();
this._topLeft.initWithTexture(selTexture, rotatedlefttopbounds, true);
- locScale9Image.addChild(this._topLeft, 2, cc.POSITIONS_TOPLEFT);
+ locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
// Top right
this._topRight = new cc.Sprite();
this._topRight.initWithTexture(selTexture, rotatedrighttopbounds, true);
- locScale9Image.addChild(this._topRight, 2, cc.POSITIONS_TOPRIGHT);
+ locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
// Bottom left
this._bottomLeft = new cc.Sprite();
this._bottomLeft.initWithTexture(selTexture, rotatedleftbottombounds, true);
- locScale9Image.addChild(this._bottomLeft, 2, cc.POSITIONS_BOTTOMLEFT);
+ locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
// Bottom right
this._bottomRight = new cc.Sprite();
this._bottomRight.initWithTexture(selTexture, rotatedrightbottombounds, true);
- locScale9Image.addChild(this._bottomRight, 2, cc.POSITIONS_BOTTOMRIGHT);
+ locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
}
this.setContentSize(rect);
@@ -981,3 +968,16 @@ cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets
return pReturn;
return null;
};
+
+
+/**
+ * @ignore
+ */
+cc.Scale9Sprite.POSITIONS_CENTRE = 0;
+cc.Scale9Sprite.POSITIONS_TOP = 1;
+cc.Scale9Sprite.POSITIONS_LEFT = 2;
+cc.Scale9Sprite.POSITIONS_RIGHT = 3;
+cc.Scale9Sprite.POSITIONS_BOTTOM = 4;
+cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5;
+cc.Scale9Sprite.POSITIONS_TOPLEFT = 6;
+cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7;
\ No newline at end of file
From 509b6eb6533a24afdfa83d290effc68bb5f51e74 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Thu, 17 Apr 2014 16:02:27 +0800
Subject: [PATCH 0022/1564] Closed #4887: Modify cc.inputManager's mouseMove
event that its button needn't pressed
---
cocos2d/core/platform/CCInputManager.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js
index 15c5d204f9..932cc6937d 100644
--- a/cocos2d/core/platform/CCInputManager.js
+++ b/cocos2d/core/platform/CCInputManager.js
@@ -378,8 +378,8 @@ cc.inputManager = /** @lends cc.inputManager# */{
}, false);
cc._addEventListener(element, "mousemove", function (event) {
- if(!selfPointer._mousePressed)
- return;
+ //if(!selfPointer._mousePressed)
+ // return;
var pos = selfPointer.getHTMLElementPosition(element);
var location = selfPointer.getPointByEvent(event, pos);
@@ -388,7 +388,10 @@ cc.inputManager = /** @lends cc.inputManager# */{
selfPointer.handleTouchesMove([selfPointer.getTouchByXY(location.x, location.y, pos)]);
var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.MOVE);
- mouseEvent.setButton(event.button);
+ if(selfPointer._mousePressed)
+ mouseEvent.setButton(event.button);
+ else
+ mouseEvent.setButton(null);
cc.eventManager.dispatchEvent(mouseEvent);
event.stopPropagation();
From 96c9b0704f16a7112ed2049ca04d433e74e59273 Mon Sep 17 00:00:00 2001
From: dingpinglv
Date: Fri, 18 Apr 2014 09:57:57 +0800
Subject: [PATCH 0023/1564] Fixed: correct some mistake for minimize core
---
CCBoot.js | 10 ++++++----
tools/build.xml | 11 ++++++-----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/CCBoot.js b/CCBoot.js
index 4fb6ae6b63..3fb53434d6 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -1450,12 +1450,14 @@ cc.game = {
/**
* Run game.
*/
- run: function () {
+ run: function (gameID) {
var self = this;
+ if(gameID)
+ self.config[self.CONFIG_KEY.id] = gameID;
if (!self._prepareCalled) {
self.prepare(function () {
if (cc._supportRender) {
- cc._setup(self.config[self.CONFIG_KEY.id]);
+ cc._setup(gameID);
self._runMainLoop();
self._eventHide = self._eventHide || new cc.EventCustom(self.EVENT_HIDE);
self._eventHide.setUserData(self);
@@ -1468,7 +1470,7 @@ cc.game = {
if (cc._supportRender) {
self._checkPrepare = setInterval(function () {
if (self._prepared) {
- cc._setup(self.config[self.CONFIG_KEY.id]);
+ cc._setup(gameID);
self._runMainLoop();
self._eventHide = self._eventHide || new cc.EventCustom(self.EVENT_HIDE);
self._eventHide.setUserData(self);
@@ -1493,7 +1495,7 @@ cc.game = {
cfg[CONFIG_KEY.engineDir] = cfg[CONFIG_KEY.engineDir] || "frameworks/cocos2d-html5";
cfg[CONFIG_KEY.debugMode] = cfg[CONFIG_KEY.debugMode] || 0;
cfg[CONFIG_KEY.frameRate] = cfg[CONFIG_KEY.frameRate] || 60;
- cfg[CONFIG_KEY.renderMode] = cfg[CONFIG_KEY.renderMode] || 0;
+ cfg[CONFIG_KEY.renderMode] = cfg[CONFIG_KEY.renderMode] || 1;
return cfg;
};
if (document["ccConfig"]) {
diff --git a/tools/build.xml b/tools/build.xml
index 61eb5c0599..7069c5466c 100644
--- a/tools/build.xml
+++ b/tools/build.xml
@@ -242,8 +242,8 @@
-
+
@@ -252,24 +252,25 @@
-
+
+
-
+
+
-
-
+
From c74f06894c0fa222c261dc47c7b5611e1341ecaf Mon Sep 17 00:00:00 2001
From: VisualSJ
Date: Fri, 18 Apr 2014 14:19:17 +0800
Subject: [PATCH 0024/1564] Fix bug that CCPartcleSystem parameter is not
defined
---
cocos2d/particle/CCParticleSystem.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index 7e5ddded0a..7db66ef7c8 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -247,10 +247,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
_allocatedParticles: 0,
//drawMode
- drawMode: cc.ParticleSystem.SHAPE_MODE,
+ drawMode: null,
//shape type
- shapeType: cc.ParticleSystem.BALL_SHAPE,
+ shapeType: null,
_isActive: false,
particleCount: 0,
duration: 0,
@@ -277,7 +277,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
_texture: null,
_blendFunc: null,
_opacityModifyRGB: false,
- positionType: cc.ParticleSystem.TYPE_FREE,
+ positionType: null,
autoRemoveOnFinish: false,
emitterMode: 0,
From 26b026d9724319b692f2d8848bc0e36a3c07f6fa Mon Sep 17 00:00:00 2001
From: VisualSJ
Date: Fri, 18 Apr 2014 14:19:47 +0800
Subject: [PATCH 0025/1564] Fix bug that document.body is not DOM, Caused
insertion error
---
CCBoot.js | 55 +++++++++++++++++------------
cocos2d/core/labelttf/CCLabelTTF.js | 10 +++++-
2 files changed, 41 insertions(+), 24 deletions(-)
diff --git a/CCBoot.js b/CCBoot.js
index 3fb53434d6..a8b9937c72 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -1450,38 +1450,47 @@ cc.game = {
/**
* Run game.
*/
- run: function (gameID) {
+ run: function (id) {
var self = this;
- if(gameID)
- self.config[self.CONFIG_KEY.id] = gameID;
- if (!self._prepareCalled) {
- self.prepare(function () {
- if (cc._supportRender) {
- cc._setup(gameID);
- self._runMainLoop();
- self._eventHide = self._eventHide || new cc.EventCustom(self.EVENT_HIDE);
- self._eventHide.setUserData(self);
- self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW);
- self._eventShow.setUserData(self);
- self.onStart();
- }
- });
- } else {
- if (cc._supportRender) {
- self._checkPrepare = setInterval(function () {
- if (self._prepared) {
- cc._setup(gameID);
+ var _run = function () {
+ if (id) {
+ self.config[self.CONFIG_KEY.id] = id;
+ }
+ if (!self._prepareCalled) {
+ self.prepare(function () {
+ if (cc._supportRender) {
+ cc._setup(self.config[self.CONFIG_KEY.id]);
self._runMainLoop();
self._eventHide = self._eventHide || new cc.EventCustom(self.EVENT_HIDE);
self._eventHide.setUserData(self);
self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW);
self._eventShow.setUserData(self);
self.onStart();
- clearInterval(self._checkPrepare);
}
- }, 10);
+ });
+ } else {
+ if (cc._supportRender) {
+ self._checkPrepare = setInterval(function () {
+ if (self._prepared) {
+ cc._setup(self.config[self.CONFIG_KEY.id]);
+ self._runMainLoop();
+ self._eventHide = self._eventHide || new cc.EventCustom(self.EVENT_HIDE);
+ self._eventHide.setUserData(self);
+ self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW);
+ self._eventShow.setUserData(self);
+ self.onStart();
+ clearInterval(self._checkPrepare);
+ }
+ }, 10);
+ }
}
- }
+ };
+ document.body ?
+ _run() :
+ cc._addEventListener(window, 'load', function () {
+ this.removeEventListener('load', arguments.callee, false);
+ _run();
+ }, false);
},
/**
* Init config.
diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js
index 3ef9e764a7..79106064a6 100644
--- a/cocos2d/core/labelttf/CCLabelTTF.js
+++ b/cocos2d/core/labelttf/CCLabelTTF.js
@@ -1175,7 +1175,15 @@ cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
-document.body.appendChild(cc.LabelTTF.__labelHeightDiv);
+
+document.body ?
+ document.body.appendChild(cc.LabelTTF.__labelHeightDiv) :
+ cc._addEventListener(window, 'load', function () {
+ this.removeEventListener('load', arguments.callee, false);
+ document.body.appendChild(cc.LabelTTF.__labelHeightDiv);
+ console.log(1);
+ }, false);
+
cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) {
var clientHeight = cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize];
From a87e6e02b54f640756977ffefa4fb01a9b742d91 Mon Sep 17 00:00:00 2001
From: VisualSJ
Date: Fri, 18 Apr 2014 14:20:00 +0800
Subject: [PATCH 0026/1564] Modify the sample
---
template/index.html | 49 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/template/index.html b/template/index.html
index 1e314249d6..9b98730a5f 100644
--- a/template/index.html
+++ b/template/index.html
@@ -19,10 +19,55 @@
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
+
+
-
-